[libvirt] [PATCH 1/2] Rename qemudShrinkDisks to virDomainDiskRemove and move to domain_conf.c
From: Soren Hansen so...@linux2go.dk Other drivers will need this same functionality, so move it to up to conf/domain_conf.c and give it a more general name. Signed-off-by: Soren Hansen so...@linux2go.dk --- src/conf/domain_conf.c | 18 ++ src/conf/domain_conf.h |2 ++ src/libvirt_private.syms |1 + src/qemu/qemu_driver.c | 20 ++-- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ee99cd1..e05d5d7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4064,6 +4064,24 @@ void virDomainDiskInsertPreAlloced(virDomainDefPtr def, } +void virDomainDiskRemove(virDomainDefPtr def, size_t i) +{ +if (def-ndisks 1) { +memmove(def-disks + i, +def-disks + i + 1, +sizeof(*def-disks) * +(def-ndisks - (i + 1))); +def-ndisks--; +if (VIR_REALLOC_N(def-disks, def-ndisks) 0) { +/* ignore, harmless */ +} +} else { +VIR_FREE(def-disks); +def-ndisks = 0; +} +} + + int virDomainControllerInsert(virDomainDefPtr def, virDomainControllerDefPtr controller) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 92f98bc..7195c04 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1067,6 +1067,8 @@ void virDomainDiskInsertPreAlloced(virDomainDefPtr def, virDomainDiskDefPtr disk); int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def); +void virDomainDiskRemove(virDomainDefPtr def, size_t i); + int virDomainControllerInsert(virDomainDefPtr def, virDomainControllerDefPtr controller); void virDomainControllerInsertPreAlloced(virDomainDefPtr def, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d5a7a73..c2905ba 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -144,6 +144,7 @@ virDomainDiskDefFree; virDomainDiskDeviceTypeToString; virDomainDiskInsert; virDomainDiskInsertPreAlloced; +virDomainDiskRemove; virDomainDiskDefAssignAddress; virDomainControllerInsert; virDomainControllerInsertPreAlloced; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 656a1e4..25695df 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8583,22 +8583,6 @@ static inline int qemudFindDisk(virDomainDefPtr def, const char *dst) return -1; } -static inline void qemudShrinkDisks(virDomainDefPtr def, size_t i) -{ -if (def-ndisks 1) { -memmove(def-disks + i, -def-disks + i + 1, -sizeof(*def-disks) * -(def-ndisks - (i + 1))); -def-ndisks--; -if (VIR_REALLOC_N(def-disks, def-ndisks) 0) { -/* ignore, harmless */ -} -} else { -VIR_FREE(def-disks); -def-ndisks = 0; -} -} static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver, virDomainObjPtr vm, @@ -8655,7 +8639,7 @@ static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver, qemuDomainPCIAddressReleaseAddr(priv-pciaddrs, detach-info) 0) VIR_WARN(Unable to release PCI address on %s, dev-data.disk-src); -qemudShrinkDisks(vm-def, i); +virDomainDiskRemove(vm-def, i); virDomainDiskDefFree(detach); @@ -8719,7 +8703,7 @@ static int qemudDomainDetachSCSIDiskDevice(struct qemud_driver *driver, } qemuDomainObjExitMonitorWithDriver(driver, vm); -qemudShrinkDisks(vm-def, i); +virDomainDiskRemove(vm-def, i); virDomainDiskDefFree(detach); -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] Support virDomainAttachDevice and virDomainDetachDevice for disks in UML
From: Soren Hansen so...@linux2go.dk UML supports hot plugging and unplugging of various devices. This patch exposes this functionality for disks. Signed-off-by: Soren Hansen so...@linux2go.dk --- src/uml/uml_driver.c | 239 +- 1 files changed, 235 insertions(+), 4 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 9cad7f1..a5c5d6a 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -1683,6 +1683,237 @@ cleanup: } +static int umlDomainAttachUmlDisk(struct uml_driver *driver, + virDomainObjPtr vm, + virDomainDiskDefPtr disk) +{ +int i, ret; +char *cmd = NULL; +char *reply = NULL; + +for (i = 0 ; i vm-def-ndisks ; i++) { +if (STREQ(vm-def-disks[i]-dst, disk-dst)) { +umlReportError(VIR_ERR_OPERATION_FAILED, + _(target %s already exists), disk-dst); +return -1; +} +} + +if (!disk-src) { +umlReportError(VIR_ERR_INTERNAL_ERROR, + %s, _(disk source path is missing)); +goto error; +} + +if (virAsprintf(cmd, config %s=%s, disk-dst, disk-src) 0) { +virReportOOMError(); +return -1; +} + +if (umlMonitorCommand(driver, vm, cmd, reply) 0) +goto error; + +if (VIR_REALLOC_N(vm-def-disks, vm-def-ndisks+1) 0) { +virReportOOMError(); +goto error; +} + +if (ret 0) +goto error; + +virDomainDiskInsertPreAlloced(vm-def, disk); + +VIR_FREE(reply); +VIR_FREE(cmd); + +return 0; + +error: + +VIR_FREE(reply); +VIR_FREE(cmd); + +return -1; +} + + +static int umlDomainAttachDevice(virDomainPtr dom, const char *xml) +{ +struct uml_driver *driver = dom-conn-privateData; +virDomainObjPtr vm; +virDomainDeviceDefPtr dev = NULL; +int ret = -1; + +umlDriverLock(driver); + +vm = virDomainFindByUUID(driver-domains, dom-uuid); +if (!vm) { +char uuidstr[VIR_UUID_STRING_BUFLEN]; +virUUIDFormat(dom-uuid, uuidstr); +umlReportError(VIR_ERR_NO_DOMAIN, + _(no domain with matching uuid '%s'), uuidstr); +goto cleanup; +} + +if (!virDomainObjIsActive(vm)) { +umlReportError(VIR_ERR_OPERATION_INVALID, + %s, _(cannot attach device on inactive domain)); +goto cleanup; +} + +dev = virDomainDeviceDefParse(driver-caps, vm-def, xml, + VIR_DOMAIN_XML_INACTIVE); + +if (dev == NULL) +goto cleanup; + +if (dev-type == VIR_DOMAIN_DEVICE_DISK) { +if (dev-data.disk-bus == VIR_DOMAIN_DISK_BUS_UML) { +ret = umlDomainAttachUmlDisk(driver, vm, dev-data.disk); +if (ret == 0) +dev-data.disk = NULL; +} else { +umlReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(disk bus '%s' cannot be hotplugged.), + virDomainDiskBusTypeToString(dev-data.disk-bus)); +} +} else { +umlReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(device type '%s' cannot be attached), + virDomainDeviceTypeToString(dev-type)); +goto cleanup; +} + +cleanup: + +virDomainDeviceDefFree(dev); +if (vm) +virDomainObjUnlock(vm); +umlDriverUnlock(driver); +return ret; +} + + +static int umlDomainAttachDeviceFlags(virDomainPtr dom, + const char *xml, + unsigned int flags) { +if (flags VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { +umlReportError(VIR_ERR_OPERATION_INVALID, + %s, _(cannot modify the persistent configuration of a domain)); +return -1; +} + +return umlDomainAttachDevice(dom, xml); +} + + +static int umlDomainDetachUmlDisk(struct uml_driver *driver, + virDomainObjPtr vm, + virDomainDeviceDefPtr dev) +{ +int i, ret = -1; +virDomainDiskDefPtr detach = NULL; +char *cmd; +char *reply; + +for (i = 0 ; i vm-def-ndisks ; i++) { +if (STREQ(vm-def-disks[i]-dst, dev-data.disk-dst)) { +break; +} +} + +if (i == vm-def-ndisks) { +umlReportError(VIR_ERR_OPERATION_FAILED, + _(disk %s not found), dev-data.disk-dst); +return -1; +} + +detach = vm-def-disks[i]; + +if (virAsprintf(cmd, remove %s, detach-dst) 0) { +virReportOOMError(); +return -1; +} + +if (umlMonitorCommand(driver, vm, cmd, reply) 0) +goto cleanup; + +virDomainDiskRemove(vm-def, i); + +virDomainDiskDefFree(detach); + +ret = 0; + +VIR_FREE(reply); + +cleanup: +VIR_FREE(cmd); + +return ret; +} + + +static int umlDomainDetachDevice(virDomainPtr
Re: [libvirt] [PATCH] xenapi: Fix compile error in previous commit
On Sat, Aug 21, 2010 at 12:33:32AM +0200, Matthias Bolte wrote: 2010/8/21 Jim Fehlig jfeh...@novell.com: Eric Blake wrote: On 08/20/2010 03:31 PM, Matthias Bolte wrote: --- I'm pushing this under the trivial compile error fix rule. { - enum virDomainLifecycleCrashAction num = VIR_DOMAIN_LIFECYCLE_CRASH__RESTART; + enum virDomainLifecycleCrashAction num = VIR_DOMAIN_LIFECYCLE_CRASH_RESTART; Oops - serves me right for testing on my RHEL 6 beta box (which lacks xen support) instead of my normal Fedora 13 box (where the compiler would have caught it as part of my review). And thanks for the quick fix. G. Sorry about that. BTW, you don't only need xen but Citrix xenserver right? I have xen installed, including the opensource xenapi headers/libs. But looking at my build logs, xenapi was not detected during configure. Regards, Jim The xenapi driver requires libxenserver which can be found here: http://community.citrix.com/display/xs/Download+SDKs Hmm, shouldn't it work with the libxen from xen-unstable.hg too - that is the original XenAPI client library IIUC ? Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/2] Rename qemudShrinkDisks to virDomainDiskRemove and move to domain_conf.c
On Mon, Aug 23, 2010 at 11:31:26AM +0200, so...@linux2go.dk wrote: From: Soren Hansen so...@linux2go.dk Other drivers will need this same functionality, so move it to up to conf/domain_conf.c and give it a more general name. Signed-off-by: Soren Hansen so...@linux2go.dk --- src/conf/domain_conf.c | 18 ++ src/conf/domain_conf.h |2 ++ src/libvirt_private.syms |1 + src/qemu/qemu_driver.c | 20 ++-- 4 files changed, 23 insertions(+), 18 deletions(-) ACK, looks good. Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] Support virDomainAttachDevice and virDomainDetachDevice for disks in UML
On Mon, Aug 23, 2010 at 11:31:27AM +0200, so...@linux2go.dk wrote: From: Soren Hansen so...@linux2go.dk UML supports hot plugging and unplugging of various devices. This patch exposes this functionality for disks. Signed-off-by: Soren Hansen so...@linux2go.dk --- src/uml/uml_driver.c | 239 +- 1 files changed, 235 insertions(+), 4 deletions(-) ACK Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Allow chardev of type 'file' for UML domains.
Like the comment suggested, we just open the file and pass the file descriptor to uml. The input stream is set to null, since I couldn't find any useful way to actually use a file for input for a chardev and this also mimics what e.g. QEmu does internally. Signed-off-by: Soren Hansen so...@linux2go.dk --- src/uml/uml_conf.c | 31 ++- src/uml/uml_conf.h |1 + src/uml/uml_driver.c | 12 +++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 42193e4..65b06c5 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -295,7 +295,8 @@ error: static char * umlBuildCommandLineChr(virDomainChrDefPtr def, - const char *dev) + const char *dev, + fd_set *keepfd) { char *ret = NULL; @@ -344,8 +345,27 @@ umlBuildCommandLineChr(virDomainChrDefPtr def, break; case VIR_DOMAIN_CHR_TYPE_FILE: -case VIR_DOMAIN_CHR_TYPE_PIPE: -/* XXX could open the file/pipe just pass the FDs */ + { +int fd_out; + +if ((fd_out = open(def-data.file.path, + O_WRONLY | O_APPEND | O_CREAT, 0660)) 0) { +virReportSystemError(errno, + _(failed to open chardev file: %s), + def-data.file.path); +return NULL; +} +if (virAsprintf(ret, %s%d=null,fd:%d, dev, def-target.port, fd_out) 0) { +virReportOOMError(); +close(fd_out); +return NULL; +} +FD_SET(fd_out, keepfd); +} +break; + case VIR_DOMAIN_CHR_TYPE_PIPE: +/* XXX could open the pipe just pass the FDs. Be wary of + * the effects of blocking I/O, though. */ case VIR_DOMAIN_CHR_TYPE_VC: case VIR_DOMAIN_CHR_TYPE_UDP: @@ -391,6 +411,7 @@ static char *umlNextArg(char *args) int umlBuildCommandLine(virConnectPtr conn, struct uml_driver *driver ATTRIBUTE_UNUSED, virDomainObjPtr vm, +fd_set *keepfd, const char ***retargv, const char ***retenv) { @@ -513,7 +534,7 @@ int umlBuildCommandLine(virConnectPtr conn, for (i = 0 ; i UML_MAX_CHAR_DEVICE ; i++) { char *ret = NULL; if (i == 0 vm-def-console) -ret = umlBuildCommandLineChr(vm-def-console, con); +ret = umlBuildCommandLineChr(vm-def-console, con, keepfd); if (!ret) if (virAsprintf(ret, con%d=none, i) 0) goto no_memory; @@ -527,7 +548,7 @@ int umlBuildCommandLine(virConnectPtr conn, if (vm-def-serials[j]-target.port == i) chr = vm-def-serials[j]; if (chr) -ret = umlBuildCommandLineChr(chr, ssl); +ret = umlBuildCommandLineChr(chr, ssl, keepfd); if (!ret) if (virAsprintf(ret, ssl%d=none, i) 0) goto no_memory; diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h index b33acc8..d8b2349 100644 --- a/src/uml/uml_conf.h +++ b/src/uml/uml_conf.h @@ -71,6 +71,7 @@ virCapsPtr umlCapsInit (void); int umlBuildCommandLine (virConnectPtr conn, struct uml_driver *driver, virDomainObjPtr dom, + fd_set *keepfd, const char ***retargv, const char ***retenv); diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 9cad7f1..e926a9f 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -811,6 +811,7 @@ static int umlStartVMDaemon(virConnectPtr conn, char *logfile; int logfd = -1; struct stat sb; +int openmax; fd_set keepfd; char ebuf[1024]; umlDomainObjPrivatePtr priv = vm-privateData; @@ -869,7 +870,7 @@ static int umlStartVMDaemon(virConnectPtr conn, return -1; } -if (umlBuildCommandLine(conn, driver, vm, +if (umlBuildCommandLine(conn, driver, vm, keepfd, argv, progenv) 0) { close(logfd); umlCleanupTapDevices(conn, vm); @@ -908,6 +909,15 @@ static int umlStartVMDaemon(virConnectPtr conn, NULL, NULL, NULL); close(logfd); +/* + * At the moment, the only thing that populates keepfd is + * umlBuildCommandLineChr. We want to close every fd it opens. + */ +openmax = sysconf (_SC_OPEN_MAX); +for (i = 0; i openmax; i++) +if (FD_ISSET(i, keepfd)) +close(i); + for (i = 0 ; argv[i] ; i++) VIR_FREE(argv[i]); VIR_FREE(argv); -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com
[libvirt] virsh create and virsh dumpxml certain code location
Hi all, My libivrt is libvirt-0.8.3 I would like to add tap2 recognition when using virsh create and dumpxml, but i could not find the certain function part that the logic of create and dumpxml are defined, Would anyone please give me some hints? Thanks Very Much Regards, Ben -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Allow chardev of type 'file' for UML domains.
On Mon, Aug 23, 2010 at 12:19:51PM +0200, Soren Hansen wrote: Like the comment suggested, we just open the file and pass the file descriptor to uml. The input stream is set to null, since I couldn't find any useful way to actually use a file for input for a chardev and this also mimics what e.g. QEmu does internally. Signed-off-by: Soren Hansen so...@linux2go.dk --- src/uml/uml_conf.c | 31 ++- src/uml/uml_conf.h |1 + src/uml/uml_driver.c | 12 +++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 9cad7f1..e926a9f 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -811,6 +811,7 @@ static int umlStartVMDaemon(virConnectPtr conn, char *logfile; int logfd = -1; struct stat sb; +int openmax; fd_set keepfd; char ebuf[1024]; umlDomainObjPrivatePtr priv = vm-privateData; @@ -869,7 +870,7 @@ static int umlStartVMDaemon(virConnectPtr conn, return -1; } -if (umlBuildCommandLine(conn, driver, vm, +if (umlBuildCommandLine(conn, driver, vm, keepfd, argv, progenv) 0) { close(logfd); umlCleanupTapDevices(conn, vm); @@ -908,6 +909,15 @@ static int umlStartVMDaemon(virConnectPtr conn, NULL, NULL, NULL); close(logfd); +/* + * At the moment, the only thing that populates keepfd is + * umlBuildCommandLineChr. We want to close every fd it opens. + */ +openmax = sysconf (_SC_OPEN_MAX); +for (i = 0; i openmax; i++) +if (FD_ISSET(i, keepfd)) +close(i); + Unfortunately fdset is one of those limited types that can't represent all possible values. So you need to use FD_SETSIZE instead of _SC_OPEN_MAX here Regards, Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Allow chardev of type 'file' for UML domains.
On 23-08-2010 12:42, Daniel P. Berrange wrote: +/* + * At the moment, the only thing that populates keepfd is + * umlBuildCommandLineChr. We want to close every fd it opens. + */ +openmax = sysconf (_SC_OPEN_MAX); +for (i = 0; i openmax; i++) +if (FD_ISSET(i, keepfd)) +close(i); + Unfortunately fdset is one of those limited types that can't represent all possible values. So you need to use FD_SETSIZE instead of _SC_OPEN_MAX here Ok, I'll fix that up, but just so that I understand: Your concern is that there might be an open file descriptor between FD_SETSIZE and _SC_OPEN_MAX that we don't want to close? -- Soren Hansen Ubuntu Developer http://www.ubuntu.com/ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Allow chardev of type 'file' for UML domains.
On Mon, Aug 23, 2010 at 12:59:16PM +0200, Soren Hansen wrote: On 23-08-2010 12:42, Daniel P. Berrange wrote: +/* + * At the moment, the only thing that populates keepfd is + * umlBuildCommandLineChr. We want to close every fd it opens. + */ +openmax = sysconf (_SC_OPEN_MAX); +for (i = 0; i openmax; i++) +if (FD_ISSET(i, keepfd)) +close(i); + Unfortunately fdset is one of those limited types that can't represent all possible values. So you need to use FD_SETSIZE instead of _SC_OPEN_MAX here Ok, I'll fix that up, but just so that I understand: Your concern is that there might be an open file descriptor between FD_SETSIZE and _SC_OPEN_MAX that we don't want to close? No, its that if you try to run FD_ISSET for i FD_SETSIZE, you'll likely have an array overflow / out of bounds, so just stop at FD_SETSIZE. When we switch to the new virCommandPtr apis we'll remove this limitation. Regards, Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Allow chardev of type 'file' for UML domains.
On 23-08-2010 13:04, Daniel P. Berrange wrote: Ok, I'll fix that up, but just so that I understand: Your concern is that there might be an open file descriptor between FD_SETSIZE and _SC_OPEN_MAX that we don't want to close? No, its that if you try to run FD_ISSET for i FD_SETSIZE, you'll likely have an array overflow / out of bounds, so just stop at FD_SETSIZE. Oh, of course. How silly of me. Thanks :) -- Soren Hansen Ubuntu Developer http://www.ubuntu.com/ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Allow chardev of type 'file' for UML domains.
Like the comment suggested, we just open the file and pass the file descriptor to uml. The input stream is set to null, since I couldn't find any useful way to actually use a file for input for a chardev and this also mimics what e.g. QEmu does internally. Signed-off-by: Soren Hansen so...@linux2go.dk --- src/uml/uml_conf.c | 31 ++- src/uml/uml_conf.h |1 + src/uml/uml_driver.c | 10 +- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 42193e4..65b06c5 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -295,7 +295,8 @@ error: static char * umlBuildCommandLineChr(virDomainChrDefPtr def, - const char *dev) + const char *dev, + fd_set *keepfd) { char *ret = NULL; @@ -344,8 +345,27 @@ umlBuildCommandLineChr(virDomainChrDefPtr def, break; case VIR_DOMAIN_CHR_TYPE_FILE: -case VIR_DOMAIN_CHR_TYPE_PIPE: -/* XXX could open the file/pipe just pass the FDs */ + { +int fd_out; + +if ((fd_out = open(def-data.file.path, + O_WRONLY | O_APPEND | O_CREAT, 0660)) 0) { +virReportSystemError(errno, + _(failed to open chardev file: %s), + def-data.file.path); +return NULL; +} +if (virAsprintf(ret, %s%d=null,fd:%d, dev, def-target.port, fd_out) 0) { +virReportOOMError(); +close(fd_out); +return NULL; +} +FD_SET(fd_out, keepfd); +} +break; + case VIR_DOMAIN_CHR_TYPE_PIPE: +/* XXX could open the pipe just pass the FDs. Be wary of + * the effects of blocking I/O, though. */ case VIR_DOMAIN_CHR_TYPE_VC: case VIR_DOMAIN_CHR_TYPE_UDP: @@ -391,6 +411,7 @@ static char *umlNextArg(char *args) int umlBuildCommandLine(virConnectPtr conn, struct uml_driver *driver ATTRIBUTE_UNUSED, virDomainObjPtr vm, +fd_set *keepfd, const char ***retargv, const char ***retenv) { @@ -513,7 +534,7 @@ int umlBuildCommandLine(virConnectPtr conn, for (i = 0 ; i UML_MAX_CHAR_DEVICE ; i++) { char *ret = NULL; if (i == 0 vm-def-console) -ret = umlBuildCommandLineChr(vm-def-console, con); +ret = umlBuildCommandLineChr(vm-def-console, con, keepfd); if (!ret) if (virAsprintf(ret, con%d=none, i) 0) goto no_memory; @@ -527,7 +548,7 @@ int umlBuildCommandLine(virConnectPtr conn, if (vm-def-serials[j]-target.port == i) chr = vm-def-serials[j]; if (chr) -ret = umlBuildCommandLineChr(chr, ssl); +ret = umlBuildCommandLineChr(chr, ssl, keepfd); if (!ret) if (virAsprintf(ret, ssl%d=none, i) 0) goto no_memory; diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h index b33acc8..d8b2349 100644 --- a/src/uml/uml_conf.h +++ b/src/uml/uml_conf.h @@ -71,6 +71,7 @@ virCapsPtr umlCapsInit (void); int umlBuildCommandLine (virConnectPtr conn, struct uml_driver *driver, virDomainObjPtr dom, + fd_set *keepfd, const char ***retargv, const char ***retenv); diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 9cad7f1..6582d95 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -869,7 +869,7 @@ static int umlStartVMDaemon(virConnectPtr conn, return -1; } -if (umlBuildCommandLine(conn, driver, vm, +if (umlBuildCommandLine(conn, driver, vm, keepfd, argv, progenv) 0) { close(logfd); umlCleanupTapDevices(conn, vm); @@ -908,6 +908,14 @@ static int umlStartVMDaemon(virConnectPtr conn, NULL, NULL, NULL); close(logfd); +/* + * At the moment, the only thing that populates keepfd is + * umlBuildCommandLineChr. We want to close every fd it opens. + */ +for (i = 0; i FD_SETSIZE; i++) +if (FD_ISSET(i, keepfd)) +close(i); + for (i = 0 ; argv[i] ; i++) VIR_FREE(argv[i]); VIR_FREE(argv); -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Allow chardev of type 'file' for UML domains.
On Mon, Aug 23, 2010 at 01:25:50PM +0200, Soren Hansen wrote: Like the comment suggested, we just open the file and pass the file descriptor to uml. The input stream is set to null, since I couldn't find any useful way to actually use a file for input for a chardev and this also mimics what e.g. QEmu does internally. Signed-off-by: Soren Hansen so...@linux2go.dk --- src/uml/uml_conf.c | 31 ++- src/uml/uml_conf.h |1 + src/uml/uml_driver.c | 10 +- 3 files changed, 36 insertions(+), 6 deletions(-) ACK, looks good now. Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] esx: Improve object-by-type lookup performance
On Sat, Aug 21, 2010 at 07:02:03PM +0200, Matthias Bolte wrote: Instead of using one big traversal spec for lookup use a set of more fine grained traversal specs that are selected based on the actual needs of the lookup. This gives up to 20% speedup for certain operations like domain listing due to less HTTP(S) traffic. --- src/esx/esx_driver.c |1 - src/esx/esx_vi.c | 223 +- src/esx/esx_vi.h | 16 ++-- 3 files changed, 121 insertions(+), 119 deletions(-) ACK Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH REPOST] esx: Add read-only storage volume access
On Mon, Aug 23, 2010 at 12:25:19AM +0200, Matthias Bolte wrote: This allows to list existing volumes and to retrieve information about them. --- src/esx/esx_driver.c | 112 +-- src/esx/esx_storage_driver.c | 433 +++- src/esx/esx_vi.c | 279 ++ src/esx/esx_vi.h |9 + src/esx/esx_vi_generator.input |7 + 5 files changed, 724 insertions(+), 116 deletions(-) +static char * +esxStorageVolumeDumpXML(virStorageVolPtr volume, unsigned int flags) +{ +esxPrivate *priv = volume-conn-storagePrivateData; +esxVI_String *propertyNameList = NULL; +esxVI_ObjectContent *datastore = NULL; +esxVI_DynamicProperty *dynamicProperty = NULL; +esxVI_DatastoreInfo *datastoreInfo = NULL; +virStoragePoolDef pool; +char *datastorePath = NULL; +esxVI_FileInfo *fileInfo = NULL; +esxVI_VmDiskFileInfo *vmDiskFileInfo = NULL; +esxVI_IsoImageFileInfo *isoImageFileInfo = NULL; +esxVI_FloppyImageFileInfo *floppyImageFileInfo = NULL; +virStorageVolDef def; +char *xml = NULL; + +virCheckFlags(0, NULL); + +memset(pool, 0, sizeof (pool)); +memset(def, 0, sizeof (def)); + +if (esxVI_EnsureSession(priv-primary) 0) { +return NULL; +} + +/* Lookup storage pool type */ +if (esxVI_String_AppendValueToList(propertyNameList, info) 0 || +esxVI_LookupDatastoreByName(priv-primary, volume-pool, +propertyNameList, datastore, +esxVI_Occurrence_RequiredItem) 0) { +goto cleanup; +} + +for (dynamicProperty = datastore-propSet; dynamicProperty != NULL; + dynamicProperty = dynamicProperty-_next) { +if (STREQ(dynamicProperty-name, info)) { +if (esxVI_DatastoreInfo_CastFromAnyType(dynamicProperty-val, +datastoreInfo) 0) { +goto cleanup; +} + +break; +} +} + +if (esxVI_LocalDatastoreInfo_DynamicCast(datastoreInfo) != NULL) { +pool.type = VIR_STORAGE_POOL_DIR; +} else if (esxVI_NasDatastoreInfo_DynamicCast(datastoreInfo) != NULL) { +pool.type = VIR_STORAGE_POOL_NETFS; +} else if (esxVI_VmfsDatastoreInfo_DynamicCast(datastoreInfo) != NULL) { +pool.type = VIR_STORAGE_POOL_FS; +} else { +ESX_ERROR(VIR_ERR_INTERNAL_ERROR, %s, + _(DatastoreInfo has unexpected type)); +goto cleanup; +} + +/* Lookup file info */ +if (virAsprintf(datastorePath, [%s] %s, volume-pool, volume-name) 0) { +virReportOOMError(); +goto cleanup; +} + +if (esxVI_LookupFileInfoByDatastorePath(priv-primary, datastorePath, +fileInfo, +esxVI_Occurrence_RequiredItem) 0) { +goto cleanup; +} + +vmDiskFileInfo = esxVI_VmDiskFileInfo_DynamicCast(fileInfo); +isoImageFileInfo = esxVI_IsoImageFileInfo_DynamicCast(fileInfo); +floppyImageFileInfo = esxVI_FloppyImageFileInfo_DynamicCast(fileInfo); + +def.name = volume-name; +def.key = datastorePath; I know that the main libvirt storage driver uses a path for 'key' currently, but if you have a choice with ESX, it would be desirable to use a 'better' unique identifier for key. The idea is that 'key' is trying to provide a unique identifier that is stable even if the volume is moved or renamed, but still points at the same underlying data. A path is fine as the catchall fallback case, but if there's a a UUID, or SCSI/iSCSI LUN WWID then that's better. ACK, to the patch anyway since we can change this later if desired. Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] New save/restore api proposal
On Thu, Aug 19, 2010 at 05:12:36PM +0200, Jean-Baptiste Rouault wrote: Hello all, I'd like to add support for save and restore to the OpenVZ and VirtualBox drivers because I have to support these operations in the application I'm working on. However, the save/restore API in its current state doesn't fit well to our needs. The main problem is that the domain definition is included inside the save file. This is problematic because between the save and the restore operations, the names of the network interfaces on the host side are likely to have changed and we can't modify them before restoring the domain. IMHO a more general approach is to set stable naming for the host devices. To summarize, what we would like to be able to do is: - save a domain and undefine it - update the domain definition to use the new names of host side interfaces - restore the domain This is why I would like to add two new functions with the following signatures (better names are probably needed): int virDomainSaveState(virDomainPtr domain, const char *to); int virDomainRestoreState(virDomainPtr domain, const char *from); The first one would do the same as virDomainSave but without prepending the domain's definition to the save file. The other function would be able to restore a domain saved by the first one. What do you think ? I really don't think we want to add yet more save/restore functions to the API. I'm not sure its even possible to implement those proposals with VirtualBox, since it can't save state to an arbitrary file. The API in the VirtualBox SDK is IProgress IConsole::saveState(). This does a managed save internally to vbox. The next time the guest is started, it will restore from this image. This maps directly to libvirt's virDomainManagedSave() API. The OpenVZ docs appear to explicitly forbid any change to the VM configugration between time of save restore. If it didn't forbid config changes, then in theory you could call virDomainDefine() after calling virDomainManagedSave() but before virDomainCreate() in order ot change the config. As for OpenVZ, the vzctl chkpnt vzctl restore commands look like they can map directly to both of the libvirt save/restore APis. The original one taking a filename, and the new managed save ones. Regards, Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] virsh question
[Adding the list] On 08/23/2010 06:26 AM, Matthew Whitehead wrote: Eric, I'm trying to get virsh domxml-from-native working for the -s and -p flags. Do you know if support for those flags is possible? If not, is there a way I could hand code them into the xml to be passed through to the command line? I'm not sure in which context you are referring to the -s and -p flags. Which command line are you trying to modify so that those flags are added? Also, as of libvirt 0.8.3, you can modify qemu command lines issued by libvirt using appropriate XML, although such modifications go behind libvirt's back and are therefore at your own risk. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/7] Support virDomainOpenConsole with QEMU
On Thu, Aug 19, 2010 at 02:44:27PM -0600, Eric Blake wrote: On 08/17/2010 11:02 AM, Daniel P. Berrange wrote: This provides an implementation of the virDomainOpenConsole API with the QEMU driver. For the streams code, this reuses most of the code previously added for the tunnelled migration streams since it is generic. * src/qemu/qemu_driver.c: Support virDomainOpenConsole --- src/qemu/qemu_driver.c | 267 +-- 1 files changed, 210 insertions(+), 57 deletions(-) +static int qemuStreamFDRead(virStreamPtr st, char *bytes, size_t nbytes) +{ ... +} else { +ret = -1; +virReportSystemError(errno, %s, + _(cannot write to stream)); s/write to/read from/ + +static int +qemuDomainOpenConsole(virDomainPtr dom, + const char *devname, + virStreamPtr st, + unsigned int flags ATTRIBUTE_UNUSED) Drop the attribute... +{ +struct qemud_driver *driver = dom-conn-privateData; +virDomainObjPtr vm = NULL; +char uuidstr[VIR_UUID_STRING_BUFLEN]; +int ret = -1; +int i; +virDomainChrDefPtr chr = NULL; +struct qemuStreamFD *qemust; ...and add virCheckFlags(0, -1) here. +if (devname) { +if (vm-def-console +STREQ(devname, vm-def-console-info.alias)) +chr = vm-def-console; +for (i = 0 ; !chr i vm-def-nserials ; i++) { +if (STREQ(devname, vm-def-serials[i]-info.alias)) +chr = vm-def-serials[i]; +} +for (i = 0 ; !chr i vm-def-nparallels ; i++) { +if (STREQ(devname, vm-def-parallels[i]-info.alias)) +chr = vm-def-parallels[i]; +} +} else { +if (vm-def-console) +chr = vm-def-console; +else if (vm-def-nserials) +chr = vm-def-serials[0]; +} Missing the check for vm-dev-nparallels when devname is NULL and there is no console or serial devices? The intended semantics are that if no alias is provided, then this will open the first console element. Most of the time this maps to the first (only) vm-def-console. Due to historic wierdness though, with a HVM guest this will instead sometimes point to vm-def-serials[0]. When I fix that mess, the 'else if' clause can be dropped here. Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] virsh question
[again, adding the list] On 08/23/2010 07:35 AM, Matthew Whitehead wrote: I want to enable gdb debugging for the qemu or qemu-kvm executables. The -s flag tells it to run qemu's gdbserver and -p tells the gdbserver to listen on a non-default (1234) port. Yes, this sounds like a perfect fit for libvirt 0.8.3's qemu monitor support. However, I did not implement that patch, so I'm not the best person to ask on how to modify your XML to inject those options. However, commit a71be01f04e7cac in libvirt.git includes some example XML that uses the new elements, such as: +domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory219200/memory + currentMemory219200/currentMemory + vcpu1/vcpu + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + source dev='/dev/HostVG/QEMUGuest1'/ + target dev='hda' bus='ide'/ + address type='drive' controller='0' bus='0' unit='0'/ +/disk +controller type='ide' index='0'/ +memballoon model='virtio'/ + /devices + qemu:commandline +qemu:arg value='-unknown'/ +qemu:arg value='parameter'/ + /qemu:commandline +/domain So, I think it is as simple as passing qemu:arg value='-p'/ from within your domain XML. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/7] Re-write virsh console to use streams
On Tue, Aug 17, 2010 at 06:02:45PM +0100, Daniel P. Berrange wrote: This re-writes the 'virsh console' command so that it uses the new streams API. This lets it run remotely and/or as a non-root user. This requires that virsh be linked against the simple event loop from libvirtd in daemon/event.c As an added bonus, it can now connect to any console device, not just the first one. * tools/Makefile.am: Link to event.c * tools/console.c, tools/console.h: Rewrite to use the virDomainOpenConsole() APIs with streams * tools/virsh.c: Support choosing the console name via --devname $NAME I've realized one problem with this patch. It breaks virsh console for Xen LXC, since I've not added virDomainOpenConsole to those drivers yet. Supporting them is easy, but it would be a big cut+paste of the QEMU driver code, so I think I need to re-work this to pull out the QEMU stream code into a reusable module for other (local) drivers to share. ESX would of course need separate code, since that's a remote driver only. Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/7] Remote driver client and server for virDomainOpenConsole
On Thu, Aug 19, 2010 at 02:29:39PM -0600, Eric Blake wrote: On 08/17/2010 11:02 AM, Daniel P. Berrange wrote: This provides an implementation of the virDomainOpenConsole API for the remote driver client and server. * daemon/remote.c: Server side impl * src/remote/remote_driver.c: Client impl * src/remote/remote_protocol.x: Wire definition --- daemon/remote.c | 52 + daemon/remote_dispatch_args.h |1 + daemon/remote_dispatch_prototypes.h |8 +++ daemon/remote_dispatch_table.h |5 ++ src/remote/remote_driver.c | 108 -- src/remote/remote_protocol.c| 13 src/remote/remote_protocol.h| 10 +++ src/remote/remote_protocol.x|8 ++- 8 files changed, 172 insertions(+), 33 deletions(-) No change to src/remote_protocol-structs? Install the dwarves package; this will double-check that you aren't breaking any existing APIs, but it will flag that this new call is an API addition worthy of an update to src/remote_protocol-structs. Fixed that. I was in the habit of doing 'cd tests make check' to avoid the wait for gnulib tests. @@ -9665,8 +9709,8 @@ processCallDispatchStream(virConnectPtr conn ATTRIBUTE_UNUSED, privst = privst-next; if (!privst) { -VIR_WARN(No registered stream matching serial=%d, proc=%d, - hdr-serial, hdr-proc); +VIR_DEBUG(No registered stream matching serial=%d, proc=%d, + hdr-serial, hdr-proc); Quite a few conversions from VIR_WARN to VIR_DEBUG in this patch. Should they be split into a separate patch, since they are independent of the new command plumbing? Yep, split them out to a separate patch Daniel -- |: Red Hat, Engineering, London-o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org-o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/3] Fix make check failures with RHEL-5 xen
When libvirt is configured using --with-rhel5-api, make check fails on a bunch of tests for xen driver. All check now pass regardless on rhel5-api. Jiri Denemark (3): xen tests: Fix missing type ioemu with rhel5-api xml2sexprtest: Remove graphics from unrelated tests xen tests: Fix PV-VFB tests with RHEL-5 API tests/xmconfigdata/test-escape-paths.cfg |2 +- tests/xmconfigdata/test-escape-paths.xml |1 + tests/xmconfigdata/test-fullvirt-localtime.cfg |2 +- tests/xmconfigdata/test-fullvirt-localtime.xml |1 + tests/xmconfigdata/test-fullvirt-new-cdrom.cfg |2 +- tests/xmconfigdata/test-fullvirt-new-cdrom.xml |1 + tests/xmconfigdata/test-fullvirt-old-cdrom.cfg |2 +- tests/xmconfigdata/test-fullvirt-old-cdrom.xml |1 + tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg |2 +- tests/xmconfigdata/test-fullvirt-parallel-tcp.xml |1 + tests/xmconfigdata/test-fullvirt-serial-file.cfg |2 +- tests/xmconfigdata/test-fullvirt-serial-file.xml |1 + tests/xmconfigdata/test-fullvirt-serial-null.cfg |2 +- tests/xmconfigdata/test-fullvirt-serial-null.xml |1 + tests/xmconfigdata/test-fullvirt-serial-pipe.cfg |2 +- tests/xmconfigdata/test-fullvirt-serial-pipe.xml |1 + tests/xmconfigdata/test-fullvirt-serial-pty.cfg|2 +- tests/xmconfigdata/test-fullvirt-serial-pty.xml|1 + tests/xmconfigdata/test-fullvirt-serial-stdio.cfg |2 +- tests/xmconfigdata/test-fullvirt-serial-stdio.xml |1 + .../test-fullvirt-serial-tcp-telnet.cfg|2 +- .../test-fullvirt-serial-tcp-telnet.xml|1 + tests/xmconfigdata/test-fullvirt-serial-tcp.cfg|2 +- tests/xmconfigdata/test-fullvirt-serial-tcp.xml|1 + tests/xmconfigdata/test-fullvirt-serial-udp.cfg|2 +- tests/xmconfigdata/test-fullvirt-serial-udp.xml|1 + tests/xmconfigdata/test-fullvirt-serial-unix.cfg |2 +- tests/xmconfigdata/test-fullvirt-serial-unix.xml |1 + tests/xmconfigdata/test-fullvirt-sound.cfg |2 +- tests/xmconfigdata/test-fullvirt-sound.xml |1 + tests/xmconfigdata/test-fullvirt-usbmouse.cfg |2 +- tests/xmconfigdata/test-fullvirt-usbmouse.xml |1 + tests/xmconfigdata/test-fullvirt-usbtablet.cfg |2 +- tests/xmconfigdata/test-fullvirt-usbtablet.xml |1 + tests/xmconfigdata/test-fullvirt-utc.cfg |2 +- tests/xmconfigdata/test-fullvirt-utc.xml |1 + tests/xmconfigdata/test-no-source-cdrom.cfg|2 +- tests/xmconfigdata/test-no-source-cdrom.xml|1 + tests/xmconfigdata/test-pci-devs.cfg |2 +- tests/xmconfigdata/test-pci-devs.xml |1 + tests/xmconfigtest.c |4 ++-- tests/xml2sexprdata/xml2sexpr-curmem.xml |1 - .../xml2sexpr-disk-block-shareable.xml |1 - tests/xml2sexprdata/xml2sexpr-fv-localtime.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-localtime.xml |1 + .../xml2sexprdata/xml2sexpr-fv-parallel-tcp.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-parallel-tcp.xml |1 + tests/xml2sexprdata/xml2sexpr-fv-serial-file.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-serial-file.xml |1 + tests/xml2sexprdata/xml2sexpr-fv-serial-null.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-serial-null.xml |1 + tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-serial-pipe.xml |1 + tests/xml2sexprdata/xml2sexpr-fv-serial-pty.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-serial-pty.xml|1 + .../xml2sexprdata/xml2sexpr-fv-serial-stdio.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-serial-stdio.xml |1 + .../xml2sexpr-fv-serial-tcp-telnet.sexpr |2 +- .../xml2sexpr-fv-serial-tcp-telnet.xml |1 + tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-serial-tcp.xml|1 + tests/xml2sexprdata/xml2sexpr-fv-serial-udp.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-serial-udp.xml|1 + tests/xml2sexprdata/xml2sexpr-fv-serial-unix.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-serial-unix.xml |1 + tests/xml2sexprdata/xml2sexpr-fv-sound.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-sound.xml |1 + tests/xml2sexprdata/xml2sexpr-fv-usbmouse.sexpr|2 +- tests/xml2sexprdata/xml2sexpr-fv-usbmouse.xml |1 + tests/xml2sexprdata/xml2sexpr-fv-utc.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-utc.xml |1 + tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv-vncunused.xml |1 + tests/xml2sexprdata/xml2sexpr-fv.sexpr |2 +- tests/xml2sexprdata/xml2sexpr-fv.xml |1 +
[libvirt] [PATCH] nodeinfotest: Print libvirt error on failure
If linuxNodeInfoCPUPopulate() fails, the test would just print FAILED which is not very informative. It's better to print the real error. --- tests/nodeinfotest.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c index d3c500d..d256c53 100644 --- a/tests/nodeinfotest.c +++ b/tests/nodeinfotest.c @@ -43,6 +43,12 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile memset(nodeinfo, 0, sizeof(nodeinfo)); if (linuxNodeInfoCPUPopulate(cpuinfo, nodeinfo) 0) { +if (virTestGetDebug()) { +virErrorPtr error = virSaveLastError(); +if (error error-code != VIR_ERR_OK) +fprintf(stderr, \n%s\n, error-message); +virFreeError(error); +} fclose(cpuinfo); return -1; } -- 1.7.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] using sync_manager with libvirt
On Sun, Aug 22, 2010 at 12:13:16PM -0400, Perry Myers wrote: On 08/19/2010 01:23 PM, David Teigland wrote: On Thu, Aug 19, 2010 at 11:12:25AM -0400, David Teigland wrote: I'm only aware of one goal, and the current plan is to implement it correctly and completely. That goal is to lock vm images so if the vm happens to run on two hosts, only one instance can access the image. Ok. So for the first implementation of sync_manager it will still be possible for someone to corrupt data by configuring two separate vms to accidentally use the same storage volumes. That's fine for the first pass, just something to keep in mind for later. Ideally, hosts should be configured from a common central point where a full view of the configuration is possible. Then it would be trivial to detect that kind of error by just looking at the configuration. If you don't have central configuration, then using a distributed system (like disk leases) to detect image assignment errors could be done, but it also pushes the problem down to the level of configuring the distributed system correctly, i.e. host id or lease area assignment errors. Dave -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] nodeinfotest: Print libvirt error on failure
On 08/23/2010 09:03 AM, Jiri Denemark wrote: If linuxNodeInfoCPUPopulate() fails, the test would just print FAILED which is not very informative. It's better to print the real error. --- tests/nodeinfotest.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/7] Re-write virsh console to use streams
2010/8/23 Daniel P. Berrange berra...@redhat.com: On Tue, Aug 17, 2010 at 06:02:45PM +0100, Daniel P. Berrange wrote: This re-writes the 'virsh console' command so that it uses the new streams API. This lets it run remotely and/or as a non-root user. This requires that virsh be linked against the simple event loop from libvirtd in daemon/event.c As an added bonus, it can now connect to any console device, not just the first one. * tools/Makefile.am: Link to event.c * tools/console.c, tools/console.h: Rewrite to use the virDomainOpenConsole() APIs with streams * tools/virsh.c: Support choosing the console name via --devname $NAME I've realized one problem with this patch. It breaks virsh console for Xen LXC, since I've not added virDomainOpenConsole to those drivers yet. Supporting them is easy, but it would be a big cut+paste of the QEMU driver code, so I think I need to re-work this to pull out the QEMU stream code into a reusable module for other (local) drivers to share. ESX would of course need separate code, since that's a remote driver only. ESX 4.0 and before can redirect a virtual serial device to file in the datastore or to a physical serial device only. One could poll for this file in the datastore via HTTPS, but that's quite ugly and I'm not sure that it would work in a reasonable way. Also this would only cover the read part, I'm not sure how to do writing that way. ESX also allows to connect two guests via a virtual null modem cable, but that would require a management guest per ESX server that runs a proxy for the virtual serial devices of other guests. Neither of this ideas sounds reasonable or even doable, so probably no virDomainOpenConsole for ESX = 4.0. Since version 4.1 ESX can export a virtual serial device via Telnet, Telnet+SSL, TCP and TCP+SSL. This will probably allow the ESX driver to support virDomainOpenConsole for ESX = 4.1. I already tested this manually using an SSL enabled Telnet client for the Telnet+SSL transport and gnutls-cli for the TCP+SSL transport and it works. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] New save/restore api proposal
On Monday 23 August 2010 14:51:51 you wrote: On Thu, Aug 19, 2010 at 05:12:36PM +0200, Jean-Baptiste Rouault wrote: Hello all, I'd like to add support for save and restore to the OpenVZ and VirtualBox drivers because I have to support these operations in the application I'm working on. However, the save/restore API in its current state doesn't fit well to our needs. The main problem is that the domain definition is included inside the save file. This is problematic because between the save and the restore operations, the names of the network interfaces on the host side are likely to have changed and we can't modify them before restoring the domain. IMHO a more general approach is to set stable naming for the host devices. This is not possible for us because our application is distributed on multiple servers. We have a huge nfs exported folder where we store all our guests' disks and private folders. A saved guest which was running on one server can be restored on another one so we can't set stable naming for the host side. I really don't think we want to add yet more save/restore functions to the API. I'm not sure its even possible to implement those proposals with VirtualBox, since it can't save state to an arbitrary file. The API in the VirtualBox SDK is IProgress IConsole::saveState(). This does a managed save internally to vbox. The next time the guest is started, it will restore from this image. This maps directly to libvirt's virDomainManagedSave() API. The OpenVZ docs appear to explicitly forbid any change to the VM configugration between time of save restore. If it didn't forbid config changes, then in theory you could call virDomainDefine() after calling virDomainManagedSave() but before virDomainCreate() in order ot change the config. The problem of the managed save API for us is that it doesn't allow to set a custom save path. We keep save states in each VM's folder so that any of our servers is able to access them. Maybe a custom managed save path could be specified in a domain's xml and then used instead of the default one ? This isn't a problem for VirtualBox because there is the adoptSavedState API. For other libvirt drivers I think this shouldn't be too difficult to implement. As for OpenVZ, the vzctl chkpnt vzctl restore commands look like they can map directly to both of the libvirt save/restore APis. The original one taking a filename, and the new managed save ones. Regards, Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] xenapi: support xenapi 5.6.0 headers
On 08/21/2010 09:52 AM, Matthias Bolte wrote: 2010/8/21 Eric Blakeebl...@redhat.com: * src/xenapi/xenapi_driver.c (xenapiDomainGetInfo): Avoid using XEN_VM_POWER_STATE_UNKNOWN, which disappeared in newer xenapi. * src/xenapi/xenapi_utils.c (mapPowerState): Likewise. --- I guess I could fold the default: and UNDEFINED: case labels into one, if that is desirable. You could make XEN_VM_POWER_STATE_UNDEFINED fall through to default as in case XEN_VM_POWER_STATE_UNDEFINED: default: /* Includes XEN_VM_POWER_STATE_UNKNOWN from libxenserver * 5.5.0, which is gone in 5.6.0. */ virState = VIR_DOMAIN_NOSTATE; break; I think that it's not desirable to remove XEN_VM_POWER_STATE_UNDEFINED completely. Agreed; your formulation looks best, so that's what I squashed in. ACK. Pushed now. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv2] PHYP: Checking for NULL values when building new guest
I fixed the way I check for invalid values and changed the way I report errors (from VIR_ERROR0 to PHYP_ERROR). I'll change the VIR_WARNs in another different patch. --- src/phyp/phyp_driver.c | 23 +++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 25d..a74eedf 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -3701,6 +3701,29 @@ phypBuildLpar(virConnectPtr conn, virDomainDefPtr def) int exit_status = 0; virBuffer buf = VIR_BUFFER_INITIALIZER; +if (def-memory 0) { +PHYP_ERROR(VIR_ERR_XML_ERROR,%s, +_(Field \memory\ on the domain XML file is missing or has +invalid value.)); +goto err; +} + +if (def-maxmem 0) { +PHYP_ERROR(VIR_ERR_XML_ERROR,%s, +_(Field \currentMemory\ on the domain XML file is missing or + has invalid value.)); +goto err; +} + +if (def-ndisks 0) { +if (!def-disks[0]-src) { +PHYP_ERROR(VIR_ERR_XML_ERROR,%s, +_(Field \src\ under \disk\ on the domain XML file is +missing.)); +goto err; +} +} + virBufferAddLit(buf, mksyscfg); if (system_type == HMC) virBufferVSprintf(buf, -m %s, managed_system); -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] xen tests: Fix missing type ioemu with rhel5-api
On 08/23/2010 09:03 AM, Jiri Denemark wrote: The most common cause of errors with rhel5-api turn on was missing (type ioemu) in sexpr or its equivalent in XM configuration file. This happens because the presence of that part in sexpr (or cfg) depends on xen version the host is running. Let's avoid it by explicitly specifying interface model which ensures type ioemu will always be emitted. This patch adds model type='e1000'/ withing the interface element in all affected xml files. And (model 'e1000') to all corresponding sexpr files with similar fix to cfg files. Such configuration works regardless on Xen version. ACK; and seems pretty mechanical to verify. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/3] xml2sexprtest: Remove graphics from unrelated tests
On 08/23/2010 09:03 AM, Jiri Denemark wrote: This caused unnecessary make check failures when libvirt is configured --with-rhel5-api --- tests/xml2sexprdata/xml2sexpr-curmem.xml |1 - .../xml2sexpr-disk-block-shareable.xml |1 - 2 files changed, 0 insertions(+), 2 deletions(-) ACK; those two tests should be unrelated to a graphics element. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] xen tests: Fix PV-VFB tests with RHEL-5 API
On 08/23/2010 09:03 AM, Jiri Denemark wrote: RHEL-5 Xen doesn't support the old style vnc configuration. In sexpr, we can't really check it with rhel5-api turned on. However, for XM configuration files it's sufficient to use cfg version 1 instead of 2. --- tests/xmconfigtest.c |4 ++-- tests/xml2sexprtest.c |5 + 2 files changed, 7 insertions(+), 2 deletions(-) ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] virsh create and virsh dumpxml certain code location
benian wrote: Hi all, My libivrt is libvirt-0.8.3 I would like to add tap2 recognition when using virsh create and dumpxml, Ah yes, I have a patch laying laying around that needs to go upstream. No better time to do that than now .. Regards, Jim From 0725b037ca494d671a41b23a72d8ac3bd9c3c58d Mon Sep 17 00:00:00 2001 From: Jim Fehlig jfeh...@novell.com Date: Mon, 23 Aug 2010 16:07:08 -0600 Subject: [PATCH] Add blktap2 support to xend driver Xen4.0 includes a new blktap2 implementation, which is specified with 'tap2' prefix. AFAICT it's configuration syntax is identical to blktap, with exception of 'tap2' vs 'tap' prefix. This patch takes the simple approach of accepting sexp containing 'tap2' prefix. --- src/xen/xend_internal.c |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index d47c625..94e5d33 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -1386,7 +1386,8 @@ xenDaemonParseSxprDisks(virDomainDefPtr def, but blktap disks ended up in a differently named (device (tap )) block */ if (sexpr_lookup(node, device/vbd) || -sexpr_lookup(node, device/tap)) { +sexpr_lookup(node, device/tap) || +sexpr_lookup(node, device/tap2)) { char *offset; const char *src = NULL; const char *dst = NULL; @@ -1397,10 +1398,14 @@ xenDaemonParseSxprDisks(virDomainDefPtr def, src = sexpr_node(node, device/vbd/uname); dst = sexpr_node(node, device/vbd/dev); mode = sexpr_node(node, device/vbd/mode); -} else { +} else if (sexpr_lookup(node, device/tap)) { src = sexpr_node(node, device/tap/uname); dst = sexpr_node(node, device/tap/dev); mode = sexpr_node(node, device/tap/mode); +} else { +src = sexpr_node(node, device/tap2/uname); +dst = sexpr_node(node, device/tap2/dev); +mode = sexpr_node(node, device/tap2/mode); } if (VIR_ALLOC(disk) 0) -- 1.6.0.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] virsh create and virsh dumpxml certain code location
Hi Jim, Thanks for your reply! I use xm create to create a tap2 disk and it works well disk = [ 'tap2:vhd:/root/tapdisk/vhd-f12,hda,w'] but virsh dumpxml can't get anything about the disk After i apply the patch, i can catch disk information by virsh dumpxml but it seems that it only recognize tap only but not tap2 disk type='file' device='disk' driver name='tap' type='vhd'/ source file='/root/tapdisk/vhd-f12'/ target dev='hda' bus='ide'/ /disk Afterwards i try to use this xml file to virsh create VM and no active disk is found. Moreover, if i change driver name='tap' to 'tap2' in xml myself, virsh seems doesn't support this type and raise error : error: POST operation failed: xend_post: error from xen daemon: (xend.err 'Error creating domain: Block device type tap2 is invalid.' Should i modify the dumpxml and create function if i want to enable tap2:vhd ?? Thank you very much! Regards, Ben 2010/8/24 Jim Fehlig jfeh...@novell.com benian wrote: Hi all, My libivrt is libvirt-0.8.3 I would like to add tap2 recognition when using virsh create and dumpxml, Ah yes, I have a patch laying laying around that needs to go upstream. No better time to do that than now .. Regards, Jim -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list