Re: [libvirt] [PATCH 0/9] Add ability to connect to LXC namespaces
On Wed, Dec 26, 2012 at 10:43:56AM +0900, Kamezawa Hiroyuki wrote: (2012/12/22 2:08), Daniel P. Berrange wrote: This series introduces an LXC specific library libvirt-lxc.so which adds ability for a process to connect to the namespaces used by an LXC container from outside. It uses FD passing magic to allow the caller to connect, even if it is not root. Can any user can execute any commands in a LXC guest by # virsh -c lxc:/// lxc-enter-namespace demo -- command without any limitation ? Well you need to be authorized to connect to lxc:/// first, which by default requires you to authorize as root on the host Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/3] add pci-bridge device and address type
On Wed, Dec 26, 2012 at 09:00:06AM +0800, liguang wrote: Now, it's unnecessary to arrange devices into multi-pci-bus, for example: sound model='ac97' address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x0'/ /sound video model type='cirrus' vram='9216' heads='1'/ address type='pci' domain='0x' bus='0x1' slot='0x02' function='0x0'/ /video libvirt will complain about bus != 0, fortunately, qemu supports pci-to-pci bridge, if we want to use multi-pci-bus, we can define 2 pci bridge devices then attach 1 to the other as a subordinate pci-bus, so, 2 pci-buses appear. for example: pci-bridge type='root'/ pci-bridge type='subordinate' address type='pci-bridge' domain='0x' bus='0x00' slot='0x04' function='0x0'/ /pci-bridge We shouldn't be introducing a new pci-bridge device for this. The existing controller element is intended to handle all types of bus devices. Just need to define a new controller type. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Adapt to new log format
On Sat, Dec 29, 2012 at 10:09:41AM +0100, Michal Privoznik wrote: Since 586502189edf9fd0f89a83de96717a2ea826fdb0 qemu commit, the log lines reporting chardev's path has changed from: $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device redirected to /dev/pts/5 char device redirected to /dev/pts/6 char device redirected to /dev/pts/7 to: $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device compat_monitor0 redirected to /dev/pts/5 char device serial0 redirected to /dev/pts/6 char device serial1 redirected to /dev/pts/7 However, with current code we are not prepared for such change, which results in us being unable to start any domain. Huh, we should not be relying on this data at all with current QEMU. We switched to using 'info chardev' / 'query-chardev' years ago. NACK to this patch. You need to find out what it is not using the monitor for this. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Adapt to new log format
On 02.01.2013 11:25, Daniel P. Berrange wrote: On Sat, Dec 29, 2012 at 10:09:41AM +0100, Michal Privoznik wrote: Since 586502189edf9fd0f89a83de96717a2ea826fdb0 qemu commit, the log lines reporting chardev's path has changed from: $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device redirected to /dev/pts/5 char device redirected to /dev/pts/6 char device redirected to /dev/pts/7 to: $ ./x86_64-softmmu/qemu-system-x86_64 -serial pty -serial pty -monitor pty char device compat_monitor0 redirected to /dev/pts/5 char device serial0 redirected to /dev/pts/6 char device serial1 redirected to /dev/pts/7 However, with current code we are not prepared for such change, which results in us being unable to start any domain. Huh, we should not be relying on this data at all with current QEMU. We switched to using 'info chardev' / 'query-chardev' years ago. NACK to this patch. You need to find out what it is not using the monitor for this. Daniel Okay, I've reverted the patch and will search for the root cause. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/6 v9] Unprivileged SG_IO support
As a result of RFC [1], this implements the unprivleged SG_IO support. 1/6 and 2/6 are already acked. v8 - v9: * Just rebasing. v7 - v8: * Change the XML tag name from cdbfilter to sgio, and to leave enough room for future values, the values of sgio are filtered and unfiltered now. v6 - v7: * No restoring of unpriv_sgio per Daniel's thought. * Use major:minor as the hash key per Jirka's suggestion. Osier Yang (6): util: Prepare helpers for unpriv_sgio setting qemu: Add a hash table for the shared disks docs: Add docs and rng schema for new XML tag sgio conf: Parse and format the new XML qemu: set unpriv_sgio when starting domain and attaching disk qemu: Check if the shared disk's cdbfilter conflicts with others docs/formatdomain.html.in | 14 ++- docs/schemas/domaincommon.rng | 54 +--- src/conf/domain_conf.c | 55 ++-- src/conf/domain_conf.h | 10 ++ src/libvirt_private.syms |4 + src/qemu/qemu_conf.c | 86 src/qemu/qemu_conf.h | 12 ++ src/qemu/qemu_driver.c | 30 src/qemu/qemu_process.c| 99 ++ src/qemu/qemu_process.h|4 + src/util/virutil.c | 140 src/util/virutil.h | 13 ++ ...qemuxml2argv-disk-scsi-lun-passthrough-sgio.xml | 32 + tests/qemuxml2xmltest.c|1 + 14 files changed, 522 insertions(+), 32 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough-sgio.xml [1] https://www.redhat.com/archives/libvir-list/2012-November/msg00988.html Regards, Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/6] docs: Add docs and rng schema for new XML tag sgio
This introduces new XML tag sgio for disk, its valid values are filtered and unfiltered, setting it as filtered will set the disk's unpriv_sgio to 0, and unfiltered to set it as 1, which allows the unprivileged SG_IO commands. --- docs/formatdomain.html.in | 14 ++- docs/schemas/domaincommon.rng | 54 +++- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 94df6f8..5e37b92 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1395,7 +1395,19 @@ rawio='yes', rawio capability will be enabled for all disks in the domain (because, in the case of QEMU, this capability can only be set on a per-process basis). This attribute is only -valid when device is lun. +valid when device is lun. NB, coderawio/code intends to +confine the capability per-device, however, current QEMU +implementation gives the domain process broader capability +than that (per-process basis, affects all the domain disks). +To confine the capability as much as possible for QEMU driver +as this stage, codesgio/code is recommended, it's more +secure than coderawio/code. +The optional codesgio/code attribute indicates whether the +kernel will filter unprivileged SG_IO commands for the disk, +valid settings are filtered or unfiltered. Defaults to +filtered. Same with coderawio/code, codesgio/code +is only valid for device 'lun'. +span class=sincesince 1.0.2/span The optional codesnapshot/code attribute indicates the default behavior of the disk during disk snapshots: internal requires a file format such as qcow2 that can store both the diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 0529d62..7a97781 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -971,24 +971,42 @@ -- define name=disk element name=disk - optional -attribute name=device - choice -valuefloppy/value -valuedisk/value -valuecdrom/value -valuelun/value - /choice -/attribute - /optional - optional -attribute name=rawio - choice -valueyes/value -valueno/value - /choice -/attribute - /optional + choice +group + optional +attribute name=device + choice +valuefloppy/value +valuedisk/value +valuecdrom/value + /choice +/attribute + /optional +/group +group + attribute name=device +choice + valuelun/value +/choice + /attribute + optional +attribute name=rawio + choice +valueyes/value +valueno/value + /choice +/attribute + /optional + optional +attribute name=sgio + choice +valuefiltered/value +valueunfiltered/value + /choice +/attribute + /optional +/group + /choice optional ref name=snapshot/ /optional -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 4/6] conf: Parse and format the new XML
Like rawio, sgio is only allowed for block disk of device type lun. It doesn't default disk-sgio to filtered when parsing, as it won't be able to distinguish explicitly requested filtered and a default filtered in driver then. We have to error out for explicit request when the kernel doesn't support the new sysfs knob unpriv_sgio, however, for defaulted filtered, we can just ignore it if the kernel doesn't support unpriv_sgio. --- src/conf/domain_conf.c | 55 +++- src/conf/domain_conf.h | 10 ...qemuxml2argv-disk-scsi-lun-passthrough-sgio.xml | 32 +++ tests/qemuxml2xmltest.c|1 + 4 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough-sgio.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 79af087..b2bc57a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -241,6 +241,12 @@ VIR_ENUM_IMPL(virDomainDiskIo, VIR_DOMAIN_DISK_IO_LAST, default, native, threads) + +VIR_ENUM_IMPL(virDomainDiskSGIO, VIR_DOMAIN_DISK_SGIO_LAST, + default, + filtered, + unfiltered) + VIR_ENUM_IMPL(virDomainIoEventFd, VIR_DOMAIN_IO_EVENT_FD_LAST, default, on, @@ -3593,6 +3599,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, char *device = NULL; char *snapshot = NULL; char *rawio = NULL; +char *sgio = NULL; char *driverName = NULL; char *driverType = NULL; char *source = NULL; @@ -3657,6 +3664,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, snapshot = virXMLPropString(node, snapshot); rawio = virXMLPropString(node, rawio); +sgio = virXMLPropString(node, sgio); cur = node-children; while (cur != NULL) { @@ -4107,22 +4115,32 @@ virDomainDiskDefParseXML(virCapsPtr caps, def-snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_NONE; } +if ((rawio || sgio) +(def-device != VIR_DOMAIN_DISK_DEVICE_LUN)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(rawio or sgio can be used only with + device='lun')); +goto error; +} + if (rawio) { def-rawio_specified = true; -if (def-device == VIR_DOMAIN_DISK_DEVICE_LUN) { -if (STREQ(rawio, yes)) { -def-rawio = 1; -} else if (STREQ(rawio, no)) { -def-rawio = 0; -} else { -virReportError(VIR_ERR_XML_ERROR, - _(unknown disk rawio setting '%s'), - rawio); -goto error; -} +if (STREQ(rawio, yes)) { +def-rawio = 1; +} else if (STREQ(rawio, no)) { +def-rawio = 0; } else { -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, - _(rawio can be used only with device='lun')); +virReportError(VIR_ERR_XML_ERROR, + _(unknown disk rawio setting '%s'), + rawio); +goto error; +} +} + +if (sgio) { +if ((def-sgio = virDomainDiskSGIOTypeFromString(sgio)) = 0) { +virReportError(VIR_ERR_XML_ERROR, + _(unknown disk sgio mode '%s'), sgio); goto error; } } @@ -4365,6 +4383,7 @@ cleanup: VIR_FREE(type); VIR_FREE(snapshot); VIR_FREE(rawio); +VIR_FREE(sgio); VIR_FREE(target); VIR_FREE(source); VIR_FREE(tray); @@ -12132,6 +12151,7 @@ virDomainDiskDefFormat(virBufferPtr buf, const char *event_idx = virDomainVirtioEventIdxTypeToString(def-event_idx); const char *copy_on_read = virDomainVirtioEventIdxTypeToString(def-copy_on_read); const char *startupPolicy = virDomainStartupPolicyTypeToString(def-startupPolicy); +const char *sgio = virDomainDiskSGIOTypeToString(def-sgio); int n; char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -12161,6 +12181,11 @@ virDomainDiskDefFormat(virBufferPtr buf, _(unexpected disk io mode %d), def-iomode); return -1; } +if (!sgio) { +virReportError(VIR_ERR_INTERNAL_ERROR, + _(Unexpected disk sgio mode '%d'), def-sgio); +return -1; +} virBufferAsprintf(buf, disk type='%s' device='%s', @@ -12172,6 +12197,10 @@ virDomainDiskDefFormat(virBufferPtr buf, virBufferAddLit(buf, rawio='no'); } } + +if (def-sgio) +virBufferAsprintf(buf, sgio='%s', sgio); + if (def-snapshot !(def-snapshot == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE def-readonly)) virBufferAsprintf(buf, snapshot='%s', diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index
[libvirt] [PATCH 1/6] util: Prepare helpers for unpriv_sgio setting
virGetDeviceID could be used across the sources, but it doesn't relate with this series, and could be done later. * src/util/virutil.h: (Declare virGetDeviceID, and vir{Get,Set}DeviceUnprivSGIO) * src/util/virutil.c: (Implement virGetDeviceID and vir{Get,Set}DeviceUnprivSGIO) * src/libvirt_private.syms: Export private symbols of upper helpers --- src/libvirt_private.syms |3 + src/util/virutil.c | 140 ++ src/util/virutil.h | 11 3 files changed, 154 insertions(+), 0 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 497d5d3..6fba1d9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1278,6 +1278,8 @@ virFileWaitForDevices; virFileWriteStr; virFindFileInPath; virFormatIntDecimal; +virGetDeviceID; +virGetDeviceUnprivSGIO; virGetGroupID; virGetGroupName; virGetHostname; @@ -1296,6 +1298,7 @@ virPipeReadUntilEOF; virScaleInteger; virSetBlocking; virSetCloseExec; +virSetDeviceUnprivSGIO; virSetInherit; virSetNonBlock; virSetUIDGID; diff --git a/src/util/virutil.c b/src/util/virutil.c index 78ca9e87..275489a 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -3129,3 +3129,143 @@ virStrIsPrint(const char *str) return true; } + +#if defined(major) defined(minor) +int +virGetDeviceID(const char *path, int *maj, int *min) +{ +struct stat sb; +char *canonical_path = NULL; + +if (virFileResolveLink(path, canonical_path) 0) +return -errno; + +if (stat(canonical_path, sb) 0) { +VIR_FREE(canonical_path); +return -errno; +} + +if (!S_ISBLK(sb.st_mode)) { +VIR_FREE(canonical_path); +return -EINVAL; +} + +if (maj) +*maj = major(sb.st_rdev); +if (min) +*min = minor(sb.st_rdev); + +VIR_FREE(canonical_path); +return 0; +} +#else +int +virGetDeviceID(const char *path ATRRIBUTE_UNUSED, + int *maj ATRRIBUTE_UNUSED, + int *min ATRRIBUTE_UNUSED) +{ + +return -ENOSYS; +} +#endif + +#define SYSFS_DEV_BLOCK_PATH /sys/dev/block + +static char * +virGetUnprivSGIOSysfsPath(const char *path, + const char *sysfs_dir) +{ +int maj, min; +char *sysfs_path = NULL; +int rc; + +if ((rc = virGetDeviceID(path, maj, min)) 0) { +virReportSystemError(-rc, + _(Unable to get device ID '%s'), + path); +return NULL; +} + +if (virAsprintf(sysfs_path, %s/%d:%d/queue/unpriv_sgio, +sysfs_dir ? sysfs_dir : SYSFS_DEV_BLOCK_PATH, +maj, min) 0) { +virReportOOMError(); +return NULL; +} + +return sysfs_path; +} + +int +virSetDeviceUnprivSGIO(const char *path, + const char *sysfs_dir, + int unpriv_sgio) +{ +char *sysfs_path = NULL; +char *val = NULL; +int ret = -1; +int rc; + +if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir))) +return -1; + +if (!virFileExists(sysfs_path)) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(unpriv_sgio is not supported by this kernel)); +goto cleanup; +} + +if (virAsprintf(val, %d, unpriv_sgio) 0) { +virReportOOMError(); +goto cleanup; +} + +if ((rc = virFileWriteStr(sysfs_path, val, 0)) 0) { +virReportSystemError(-rc, _(failed to set %s), sysfs_path); +goto cleanup; +} + +ret = 0; +cleanup: +VIR_FREE(sysfs_path); +VIR_FREE(val); +return ret; +} + +int +virGetDeviceUnprivSGIO(const char *path, + const char *sysfs_dir, + int *unpriv_sgio) +{ +char *sysfs_path = NULL; +char *buf = NULL; +char *tmp = NULL; +int ret = -1; + +if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir))) +return -1; + +if (!virFileExists(sysfs_path)) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(unpriv_sgio is not supported by this kernel)); +goto cleanup; +} + +if (virFileReadAll(sysfs_path, 1024, buf) 0) +goto cleanup; + +if ((tmp = strchr(buf, '\n'))) +*tmp = '\0'; + +if (virStrToLong_i(buf, NULL, 10, unpriv_sgio) 0) { +virReportError(VIR_ERR_INTERNAL_ERROR, + _(failed to parse value of %s), sysfs_path); +goto cleanup; +} + +ret = 0; +cleanup: +VIR_FREE(sysfs_path); +VIR_FREE(buf); +return ret; +} diff --git a/src/util/virutil.h b/src/util/virutil.h index e5116ed..634dcaf 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -281,4 +281,15 @@ bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); bool virValidateWWN(const char *wwn); bool virStrIsPrint(const char *str); + +int virGetDeviceID(const char
[libvirt] [PATCH 2/6] qemu: Add a hash table for the shared disks
This introduces a hash table for qemu driver, to store the shared disk's info as (@major:minor, @ref_count). @ref_count is the number of domains which shares the disk. Since we only care about if the disk support unprivileged SG_IO commands, and the SG_IO commands only make sense for block disk, this patch only manages (add/remove hash entry) the shared disk for block disk. * src/qemu/qemu_conf.h: (Add member 'sharedDisks' of type virHashTablePtr; Declare helpers qemuGetSharedDiskKey, qemuAddSharedDisk and qemuRemoveSharedDisk) * src/qemu/qemu_conf.c (Implement the 3 helpers) * src/qemu/qemu_process.c (Update 'sharedDisks' when domain starting and shutdown) * src/qemu/qemu_driver.c (Update 'sharedDisks' when attaching or detaching disk). --- src/qemu/qemu_conf.c| 86 +++ src/qemu/qemu_conf.h| 12 ++ src/qemu/qemu_driver.c | 22 src/qemu/qemu_process.c | 15 4 files changed, 135 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c6deb10..8440247 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -552,3 +552,89 @@ qemuDriverCloseCallbackRunAll(virQEMUDriverPtr driver, virHashForEach(driver-closeCallbacks, qemuDriverCloseCallbackRun, data); } + +/* Construct the hash key for sharedDisks as major:minor */ +char * +qemuGetSharedDiskKey(const char *disk_path) +{ +int major, minor; +char *key = NULL; +int rc; + +if ((rc = virGetDeviceID(disk_path, major, minor)) 0) { +virReportSystemError(-rc, + _(Unable to get minor number of device '%s'), + disk_path); +return NULL; +} + +if (virAsprintf(key, %d:%d, major, minor) 0) { +virReportOOMError(); +return NULL; +} + +return key; +} + +/* Increase ref count if the entry already exists, otherwise + * add a new entry. + */ +int +qemuAddSharedDisk(virHashTablePtr sharedDisks, + const char *disk_path) +{ +size_t *ref = NULL; +char *key = NULL; + +if (!(key = qemuGetSharedDiskKey(disk_path))) +return -1; + +if ((ref = virHashLookup(sharedDisks, key))) { +if (virHashUpdateEntry(sharedDisks, key, ++ref) 0) { + VIR_FREE(key); + return -1; +} +} else { +if (virHashAddEntry(sharedDisks, key, (void *)0x1)) { +VIR_FREE(key); +return -1; +} +} + +VIR_FREE(key); +return 0; +} + +/* Decrease the ref count if the entry already exists, otherwise + * remove the entry. + */ +int +qemuRemoveSharedDisk(virHashTablePtr sharedDisks, + const char *disk_path) +{ +size_t *ref = NULL; +char *key = NULL; + +if (!(key = qemuGetSharedDiskKey(disk_path))) +return -1; + +if (!(ref = virHashLookup(sharedDisks, key))) { +VIR_FREE(key); +return -1; +} + +if (ref != (void *)0x1) { +if (virHashUpdateEntry(sharedDisks, key, --ref) 0) { + VIR_FREE(key); + return -1; +} +} else { +if (virHashRemoveEntry(sharedDisks, key) 0) { +VIR_FREE(key); +return -1; +} +} + +VIR_FREE(key); +return 0; +} diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 1aa56cc..965eff7 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -148,6 +148,8 @@ struct _virQEMUDriver { /* The devices which is are not in use by the host or any guest. */ pciDeviceList *inactivePciHostdevs; +virHashTablePtr sharedDisks; + virBitmapPtr reservedRemotePorts; virSysinfoDefPtr hostsysinfo; @@ -212,4 +214,14 @@ qemuDriverCloseCallback qemuDriverCloseCallbackGet(virQEMUDriverPtr driver, void qemuDriverCloseCallbackRunAll(virQEMUDriverPtr driver, virConnectPtr conn); +int qemuAddSharedDisk(virHashTablePtr sharedDisks, + const char *disk_path) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + +int qemuRemoveSharedDisk(virHashTablePtr sharedDisks, + const char *disk_path) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +char * qemuGetSharedDiskKey(const char *disk_path) +ATTRIBUTE_NONNULL(1); + #endif /* __QEMUD_CONF_H */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b8bb36b..bdaabdf 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -843,6 +843,9 @@ qemuStartup(bool privileged, if ((qemu_driver-inactivePciHostdevs = pciDeviceListNew()) == NULL) goto error; +if (!(qemu_driver-sharedDisks = virHashCreate(30, NULL))) +goto error; + if (privileged) { if (chown(qemu_driver-libDir, qemu_driver-user, qemu_driver-group) 0) {
[libvirt] [PATCH 6/6] qemu: Check if the shared disk's cdbfilter conflicts with others
This prevents domain starting and disk attaching if the shared disk's setting conflicts with other active domain(s), E.g. A domain with sgio set as filtered, however, another active domain is using it set as unfiltered. --- src/qemu/qemu_driver.c |5 src/qemu/qemu_process.c | 53 +++ src/qemu/qemu_process.h |3 ++ 3 files changed, 61 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9ea484c..d378a8d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5814,6 +5814,11 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, goto end; } +if (disk-type == VIR_DOMAIN_DISK_TYPE_BLOCK +disk-shared +(qemuCheckSharedDisk(driver-sharedDisks, disk) 0)) +goto end; + if (qemuDomainDetermineDiskChain(driver, disk, false) 0) goto end; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 47dae1a..76cd51a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3412,6 +3412,56 @@ qemuSetUnprivSGIO(virDomainDiskDefPtr disk) return 0; } +/* Check if a shared disk's setting conflicts with the conf + * used by other domain(s). Currently only checks the sgio + * setting. Note that this should only be called for disk with + * block source. + * + * Returns 0 if no conflicts, otherwise returns -1. + */ +int +qemuCheckSharedDisk(virHashTablePtr sharedDisks, +virDomainDiskDefPtr disk) +{ +int val; +size_t *ref = NULL; +char *key = NULL; +int ret = 0; + +if (!(key = qemuGetSharedDiskKey(disk-src))) +return -1; + +/* It can't be conflict if no other domain is + * is sharing it. + */ +if (!(ref = virHashLookup(sharedDisks, key))) +goto cleanup; + +if (ref == (void *)0x1) +goto cleanup; + +if (virGetDeviceUnprivSGIO(disk-src, NULL, val) 0) { +ret = -1; +goto cleanup; +} + +if ((val == 0 + (disk-sgio == VIR_DOMAIN_DISK_SGIO_FILTERED || + disk-sgio == VIR_DOMAIN_DISK_SGIO_DEFAULT)) || +(val == 1 + disk-sgio == VIR_DOMAIN_DISK_SGIO_UNFILTERED)) +goto cleanup; + +virReportError(VIR_ERR_OPERATION_INVALID, + _(sgio of shared disk '%s' conflicts with other + active domains), disk-src); +ret = -1; + +cleanup: +VIR_FREE(key); +return ret; +} + int qemuProcessStart(virConnectPtr conn, virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3760,6 +3810,9 @@ int qemuProcessStart(virConnectPtr conn, if (disk-type == VIR_DOMAIN_DISK_TYPE_BLOCK disk-shared) { if (qemuAddSharedDisk(driver-sharedDisks, disk-src) 0) goto cleanup; + +if (qemuCheckSharedDisk(driver-sharedDisks, disk) 0) +goto cleanup; } if (qemuSetUnprivSGIO(disk) 0) diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 52a298d..313fa39 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -100,4 +100,7 @@ virBitmapPtr qemuPrepareCpumap(virQEMUDriverPtr driver, virBitmapPtr nodemask); int qemuSetUnprivSGIO(virDomainDiskDefPtr disk); +int qemuCheckSharedDisk(virHashTablePtr sharedDisks, +virDomainDiskDefPtr disk); + #endif /* __QEMU_PROCESS_H__ */ -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 5/6] qemu: set unpriv_sgio when starting domain and attaching disk
This ignores the default filtered if unpriv_sgio is not supported by kernel, but for explicit request filtered, it error out for domain starting. --- src/libvirt_private.syms |1 + src/qemu/qemu_driver.c | 15 +-- src/qemu/qemu_process.c | 31 +++ src/qemu/qemu_process.h |1 + src/util/virutil.c |2 +- src/util/virutil.h |2 ++ 6 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6fba1d9..7472254 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1283,6 +1283,7 @@ virGetDeviceUnprivSGIO; virGetGroupID; virGetGroupName; virGetHostname; +virGetUnprivSGIOSysfsPath; virGetUserCacheDirectory; virGetUserConfigDirectory; virGetUserDirectory; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bdaabdf..9ea484c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5865,12 +5865,15 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, NULLSTR(disk-src)); } -if (ret == 0 -disk-type == VIR_DOMAIN_DISK_TYPE_BLOCK -disk-shared) { -if (qemuAddSharedDisk(driver-sharedDisks, disk-src) 0) -VIR_WARN(Failed to add disk '%s' to shared disk table, - disk-src); +if (ret == 0) { +if (disk-type == VIR_DOMAIN_DISK_TYPE_BLOCK disk-shared) { +if (qemuAddSharedDisk(driver-sharedDisks, disk-src) 0) +VIR_WARN(Failed to add disk '%s' to shared disk table, + disk-src); +} + +if (qemuSetUnprivSGIO(disk) 0) +VIR_WARN(Failed to set unpriv_sgio of disk '%s', disk-src); } end: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2a1b6b7..47dae1a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3384,6 +3384,34 @@ qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver) virHashForEach(driver-domains.objs, qemuProcessReconnectHelper, data); } +int +qemuSetUnprivSGIO(virDomainDiskDefPtr disk) +{ +int val = -1; + +if (disk-sgio) +val = (disk-sgio == VIR_DOMAIN_DISK_SGIO_UNFILTERED); + +/* Ignore the setting if unpriv_sgio is not supported by the + * kernel, otherwise defaults to filter the SG_IO commands, + * I.E. Set unpriv_sgio to 0. + */ +if (disk-sgio == VIR_DOMAIN_DISK_SGIO_DEFAULT +disk-device == VIR_DOMAIN_DISK_DEVICE_LUN) { +char *sysfs_path = NULL; + +if ((sysfs_path = virGetUnprivSGIOSysfsPath(disk-src, NULL)) +virFileExists(sysfs_path)) +val = 0; +VIR_FREE(sysfs_path); +} + +if (val = 0 virSetDeviceUnprivSGIO(disk-src, NULL, val) 0) +return -1; + +return 0; +} + int qemuProcessStart(virConnectPtr conn, virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3733,6 +3761,9 @@ int qemuProcessStart(virConnectPtr conn, if (qemuAddSharedDisk(driver-sharedDisks, disk-src) 0) goto cleanup; } + +if (qemuSetUnprivSGIO(disk) 0) +goto cleanup; } virCommandSetPreExecHook(cmd, qemuProcessHook, hookData); diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index c12df32..52a298d 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -98,5 +98,6 @@ bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver, virDomainObjPtr vm); virBitmapPtr qemuPrepareCpumap(virQEMUDriverPtr driver, virBitmapPtr nodemask); +int qemuSetUnprivSGIO(virDomainDiskDefPtr disk); #endif /* __QEMU_PROCESS_H__ */ diff --git a/src/util/virutil.c b/src/util/virutil.c index 275489a..47ab17f 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -3171,7 +3171,7 @@ virGetDeviceID(const char *path ATRRIBUTE_UNUSED, #define SYSFS_DEV_BLOCK_PATH /sys/dev/block -static char * +char * virGetUnprivSGIOSysfsPath(const char *path, const char *sysfs_dir) { diff --git a/src/util/virutil.h b/src/util/virutil.h index 634dcaf..5a08c81 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -291,5 +291,7 @@ int virSetDeviceUnprivSGIO(const char *path, int virGetDeviceUnprivSGIO(const char *path, const char *sysfs_dir, int *unpriv_sgio); +char * virGetUnprivSGIOSysfsPath(const char *path, + const char *sysfs_dir); #endif /* __VIR_UTIL_H__ */ -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] libvirtd segfault
On 12/29/2012 04:09 AM, Michal Privoznik wrote: On 28.12.2012 20:23, Scott Sullivan wrote: snip/ I have just now received another SIGSEGV, with your patch applied. Here's the info from the GDB session: Detaching after fork from child process 11266. 2012-12-28 18:56:53.261+: 29943: error : qemuMonitorIO:614 : internal error End of file from monitor Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffec0cd700 (LWP 29955)] qemuDomainObjBeginJobInternal (driver=0x7fffe4013520, driver_locked=true, obj=0x7fff7801fc80, job=QEMU_JOB_DESTROY, asyncJob=QEMU_ASYNC_JOB_NONE) at qemu/qemu_domain.c:780 780 priv-jobs_queued++; (gdb) bt #0 qemuDomainObjBeginJobInternal (driver=0x7fffe4013520, driver_locked=true, obj=0x7fff7801fc80, job=QEMU_JOB_DESTROY, asyncJob=QEMU_ASYNC_JOB_NONE) at qemu/qemu_domain.c:780 #1 0x7fffea599f46 in qemuDomainDestroyFlags (dom=value optimized out, flags=value optimized out) at qemu/qemu_driver.c:2189 #2 0x77a83587 in virDomainDestroy (domain=0x7fffe414a510) at libvirt.c:2215 #3 0x004296e2 in remoteDispatchDomainDestroy (server=value optimized out, client=value optimized out, msg=value optimized out, rerr=0x7fffec0ccbc0, args=value optimized out, ret=value optimized out) at remote_dispatch.h:1277 #4 remoteDispatchDomainDestroyHelper (server=value optimized out, client=value optimized out, msg=value optimized out, rerr=0x7fffec0ccbc0, args=value optimized out, ret=value optimized out) at remote_dispatch.h:1255 #5 0x77ad0d02 in virNetServerProgramDispatchCall (prog=0x6814d0, server=0x678df0, client=0x693a80, msg=0x6986d0) at rpc/virnetserverprogram.c:431 #6 virNetServerProgramDispatch (prog=0x6814d0, server=0x678df0, client=0x693a80, msg=0x6986d0) at rpc/virnetserverprogram.c:304 #7 0x77aceaa6 in virNetServerProcessMsg (srv=value optimized out, client=0x693a80, prog=value optimized out, msg=0x6986d0) at rpc/virnetserver.c:173 #8 0x77acf5e3 in virNetServerHandleJob (jobOpaque=value optimized out, opaque=0x678df0) at rpc/virnetserver.c:194 #9 0x779e8fdc in virThreadPoolWorker (opaque=value optimized out) at util/threadpool.c:144 #10 0x779e88c9 in virThreadHelper (data=value optimized out) at util/threads-pthread.c:161 #11 0x00300a2077f1 in start_thread () from /lib64/libpthread.so.0 #12 0x003009ae570d in clone () from /lib64/libc.so.6 (gdb) This means, even though we successfully incremented reference counter on virDomainObjPtr object, somebody free()d it anyway (well, the privateData at least). Looks like a locking/concurrent access issue to me then. Unfortunately, I don't have any suggestions yet, as the domain object is supposed to be locked when entering the qemuDomainObjBeginJobInternal() function so it shouldn't get free()d meanwhile. Michal Michal, I have a faster way to reproduce the crash (~10 minutes). Continue to read for new (easier) steps. This test was done with the standard v1.0.0 libvirtd code source, with no other patches applied. Here is the end result from the standard libvirt.log after the crash was reproduced, outside gdb: 2013-01-02 14:05:40.775+: 20383: error : qemuProcessWaitForMonitor:1700 : internal error process exited while connecting to monitor: char device redirected to /dev/pts/18 qemu: terminating on signal 15 from pid 20198 Caught Segmentation violation dumping internal log buffer: == start of log = ^@: OBJECT_UNREF: obj=0x754200 2013-01-02 14:05:40.655+20198: debug : virEventPollDispatchHandles:484 : i=3 w=4 2013-01-02 14:05:40.655+20198: debug : virEventPollDispatchHandles:484 : i=4 w=5 2013-01-02 14:05:40.655+20198: debug : virEventPollDispatchHandles:484 : i=5 w=6 snip Here's the script I used: #!/usr/bin/env perl use strict; use warnings; use threads; use threads::shared; my $upper_bound = $ARGV[0] || die No upper bound specified!\n; my $id = $ARGV[1] || die No id specified!\n; sub _shutdown_lvm { print \tvirsh destroy $id\n; system(virsh destroy $id); } sub _start_lvm { print \tvirsh create /xen/configs/$id.cfg\n; system(virsh create /xen/configs/$id.cfg); } sub _sequence { my $num = shift; print started thread $num\n; _shutdown_lvm(); _start_lvm(); print done with thread $num\n; return $num; } my @threads; for ( my $count = 1; $count = $upper_bound; $count++) { my $t = threads-new(\_sequence, $count); push(@threads,$t); } foreach (@threads) { my $num = $_-join; print done with $num\n; } I then ran it, with these args: perl libvirt_crash.pl 9 zzueyjvh I then got the segfault within 10 minutes: 2013-01-02 14:16:39.820+: 4627: error : qemuProcessWaitForMonitor:1700 : internal error process exited while connecting to monitor: char device redirected to /dev/pts/22 qemu: terminating on signal 15 from pid 3501
[libvirt] [PATCH] Remove the inexistent function in comments
virNodeDeviceLookupByKey is inexistent. --- Pushed under trivial rule. --- include/libvirt/libvirt.h.in |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index c6739d7..2de6835 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -3113,10 +3113,9 @@ typedef struct _virNodeDevice virNodeDevice; * virNodeDevicePtr: * * A virNodeDevicePtr is a pointer to a virNodeDevice structure. Get - * one via virNodeDeviceLookupByKey, virNodeDeviceLookupByName, or - * virNodeDeviceCreate. Be sure to Call virNodeDeviceFree when done - * using a virNodeDevicePtr obtained from any of the above functions to - * avoid leaking memory. + * one via, virNodeDeviceLookupByName, or virNodeDeviceCreate. Be sure + * to Call virNodeDeviceFree when done using a virNodeDevicePtr obtained + * from any of the above functions to avoid leaking memory. */ typedef virNodeDevice *virNodeDevicePtr; -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Remove the inexistent function in comments
On 01/02/2013 07:43 AM, Osier Yang wrote: virNodeDeviceLookupByKey is inexistent. s/inexistent/nonexistent/ --- Pushed under trivial rule. Oh well, it needs a followup for grammar: --- include/libvirt/libvirt.h.in |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index c6739d7..2de6835 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -3113,10 +3113,9 @@ typedef struct _virNodeDevice virNodeDevice; * virNodeDevicePtr: * * A virNodeDevicePtr is a pointer to a virNodeDevice structure. Get - * one via virNodeDeviceLookupByKey, virNodeDeviceLookupByName, or - * virNodeDeviceCreate. Be sure to Call virNodeDeviceFree when done - * using a virNodeDevicePtr obtained from any of the above functions to - * avoid leaking memory. + * one via, virNodeDeviceLookupByName, or virNodeDeviceCreate. Be sure s/via, virNodeDeviceLookupByName,/via virNodeDeviceLookupByName/ + * to Call virNodeDeviceFree when done using a virNodeDevicePtr obtained and while touching this, s/Call/call/ + * from any of the above functions to avoid leaking memory. */ typedef virNodeDevice *virNodeDevicePtr; -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] qemu: Don't parse log output when starting up a domain
Despite our great effort we still parsed qemu log output. We wouldn't notice unless qemu changed the format of the logs slightly. Anyway, now we should gather all interesting knobs like pty paths from monitor. Moreover, since for historical reasons the first console can be just an alias to the first serial port, we need to check this and copy the pty path if that's the case to the first console. --- src/qemu/qemu_capabilities.c | 7 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_process.c | 20 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 17e6679..f49a31c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1695,6 +1695,7 @@ qemuCapsPtr qemuCapsNewCopy(qemuCapsPtr caps) virBitmapCopy(ret-flags, caps-flags); +ret-usedQMP = caps-usedQMP; ret-version = caps-version; ret-kvmVersion = caps-kvmVersion; ret-arch = caps-arch; @@ -2633,3 +2634,9 @@ qemuCapsCacheFree(qemuCapsCachePtr cache) virMutexDestroy(cache-lock); VIR_FREE(cache); } + +bool +qemuCapsUsedQMP(qemuCapsPtr caps) +{ +return caps-usedQMP; +} diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3457852..1417d7f 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -241,4 +241,5 @@ int qemuCapsParseDeviceStr(qemuCapsPtr caps, const char *str); VIR_ENUM_DECL(qemuCaps); +bool qemuCapsUsedQMP(qemuCapsPtr caps); #endif /* __QEMU_CAPABILITIES_H__*/ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index eac6553..ff88192 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1532,6 +1532,7 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm, virHashTablePtr paths) { bool chardevfmt = qemuCapsGet(caps, QEMU_CAPS_CHARDEV); +int i = 0; if (qemuProcessLookupPTYs(vm-def-serials, vm-def-nserials, paths, chardevfmt) 0) @@ -1544,8 +1545,23 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm, if (qemuProcessLookupPTYs(vm-def-channels, vm-def-nchannels, paths, chardevfmt) 0) return -1; +/* For historical reasons, console[0] can be just an alias + * for serial[0]; That's why we need to update it as well */ +if (vm-def-nconsoles) { +virDomainChrDefPtr chr = vm-def-consoles[0]; + +if (vm-def-nserials +chr-deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE +chr-targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) { +/* yes, the first console is just an alias for serials[0] */ +i = 1; +if (virDomainChrSourceDefCopy(chr-source, + ((vm-def-serials[0])-source)) 0) +return -1; +} +} -if (qemuProcessLookupPTYs(vm-def-consoles, vm-def-nconsoles, +if (qemuProcessLookupPTYs(vm-def-consoles + i, vm-def-nconsoles - i, paths, chardevfmt) 0) return -1; @@ -1650,7 +1666,7 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver, virHashTablePtr paths = NULL; qemuDomainObjPrivatePtr priv; -if (pos != -1) { +if (!qemuCapsUsedQMP(caps) pos != -1) { if ((logfd = qemuDomainOpenLog(driver, vm, pos)) 0) return -1; -- 1.8.0.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Remove the inexistent function in comments
On 2013年01月02日 23:04, Eric Blake wrote: On 01/02/2013 07:43 AM, Osier Yang wrote: virNodeDeviceLookupByKey is inexistent. s/inexistent/nonexistent/ --- Pushed under trivial rule. Oh well, it needs a followup for grammar: --- include/libvirt/libvirt.h.in |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index c6739d7..2de6835 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -3113,10 +3113,9 @@ typedef struct _virNodeDevice virNodeDevice; * virNodeDevicePtr: * * A virNodeDevicePtr is a pointer to a virNodeDevice structure. Get - * one via virNodeDeviceLookupByKey, virNodeDeviceLookupByName, or - * virNodeDeviceCreate. Be sure to Call virNodeDeviceFree when done - * using a virNodeDevicePtr obtained from any of the above functions to - * avoid leaking memory. + * one via, virNodeDeviceLookupByName, or virNodeDeviceCreate. Be sure s/via, virNodeDeviceLookupByName,/via virNodeDeviceLookupByName/ + * to Call virNodeDeviceFree when done using a virNodeDevicePtr obtained and while touching this, s/Call/call/ + * from any of the above functions to avoid leaking memory. */ typedef virNodeDevice *virNodeDevicePtr; Pushed this follow up fix, thanks. diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 2de6835..cc3fe13 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -3113,8 +3113,8 @@ typedef struct _virNodeDevice virNodeDevice; * virNodeDevicePtr: * * A virNodeDevicePtr is a pointer to a virNodeDevice structure. Get - * one via, virNodeDeviceLookupByName, or virNodeDeviceCreate. Be sure - * to Call virNodeDeviceFree when done using a virNodeDevicePtr obtained + * one via virNodeDeviceLookupByName, or virNodeDeviceCreate. Be sure + * to call virNodeDeviceFree when done using a virNodeDevicePtr obtained * from any of the above functions to avoid leaking memory. */ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] RFC: An embedded mode for QEMU/LXC drivers
This is something I was thinking about a little over the christmas break. I've no intention of implementing this in the immediate future, but wanted to post it while it was fresh in my mind. Historically we have had 2 ways of using the stateful drivers like QEMU/LXC/UML/etc. - system mode - privileged libvirtd, one per host, started at boot - session mode - unprivileged libvirtd, one per non-root user, autostarted Within context of each daemon, VM name uniqueness is enforced. Operating via the daemon means that all applications connected to libvirtd get the same world view. This single world view is exactly what you want when dealing with server / cloud / desktop virtualization, because it means tools like 'virt-top', 'virt-viewer', 'virsh' can see the same VMs as virt-manager / oVirt / OpenStack / Boxes / etc. Recently we've seen increasing importance of a new use case which I will refer to as embedded virtualization. The best example of this use case is libguestfs which has long run a dedicated QEMU instance, but just now switched to using libvirtd. The other use case is virt-sandbox which is doing application confinement using LXC/KVM. In both these cases, operating via libvirtd is sub-optimal. Users of so called embedded virtualization, explicitly don't want to have interaction with other libvirt applications. They likely don't even want to expose the concept of virtualization to their users. For them virtualization is intended to be just a hidden impl detail of their application. Some issues which arise when using embedded virtualization - Need to invent sensible unique names for each VM launched. This leads to pollution of logfiles for QEMU instances run. - User sees libguestfs / virt-sandbox VMs in virt-manager / oVirt which they may then try to manage, breaking libguestfs / etc - Disassociated process context, so if 'virt-sandbox' is placed in a cgroup, the VMs it launches are in a different cgroup. Likewise if custom env variables are set, work is needed to propagate those to VMs. This leads me to wonder whether it is worth exploring the idea of a new type of libvirt connection. - embed mode - no libvirtd, driver runs in application context The idea here is to take libvirtd out of the equation and directly use the QEMU driver code in the libvirt.so client / application. Since libvirtd (mostly) uses the same APIs as the public libvirt.so clients, there isn't much required to make this work. - A way for the application to invoke virStateInit for the driver - Application must provide an event loop impl - A way to specify alternative dirs for logs/state/config/etc An application would access this mode using a different path for the driver, and specifying the path to use for logs/state/config etc. eg libguestfs might use qemu:///embed?statedir=/tmp/libguestfsX/ to get an instance of the QEMU driver that is completely private to itself. One question is whether there should be a single embed instance per process, or whether an application should be allowed to open multiple completely isolated embed instances. The latter might require is to eliminate more static variables in our code. This kind of embedded mode is not without its downsides though - How to access virtual network / storage / node device APIs ? - Extra SELinux policy work to allow each app to have the same kind of privileges that libvirtd has to let it start VMs - How to troubleshoot - can't use things like 'virsh qemu-monitor-command' since the embedded instance is private to the application in question. One answer to the latter question, might be to actually allow the application to expose the same RPC service as libvirtd does. So virsh could connect to libguestfs using qemu:///embed?socketdir=/tmp/libguestfsX/libvirt-sock For the question of network/storage/node device access, the long term answer is probably to split up the system libvirtd instance into separate pieces. eg a virtnodedeviced, virtnetworkd, virstoraged, virtqemud, virtlxcd, etc. Now a client app would connect to their embedded QEMU instances, but to the shared nodedevice/network/storage daemons. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv2 1/5] api: Add API to tunnel a guest channel via stream
This patch adds a new API, virDomainOpenChannel, that uses streams to connect to a virtio channel on a guest. This creates a secure communication channel between a guest and a libvirt client. This behaves the same as virDomainOpenConsole, except on channels instead of console/serial/parallel devices. --- include/libvirt/libvirt.h.in | 16 src/driver.h | 7 + src/libvirt.c| 61 src/libvirt_public.syms | 5 src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 9 ++- src/remote_protocol-structs | 6 + 7 files changed, 104 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 2de6835..78262a2 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -4547,6 +4547,22 @@ int virDomainOpenConsole(virDomainPtr dom, virStreamPtr st, unsigned int flags); +/** + * virDomainChannelFlags + * + * Since 1.0.2 + */ +typedef enum { +VIR_DOMAIN_CHANNEL_FORCE = (1 0), /* abort a (possibly) active channel +connection to force a new +connection */ +} virDomainChannelFlags; + +int virDomainOpenChannel(virDomainPtr dom, + const char *name, + virStreamPtr st, + unsigned int flags); + typedef enum { VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH = (1 0), } virDomainOpenGraphicsFlags; diff --git a/src/driver.h b/src/driver.h index 64d652f..01c95cf 100644 --- a/src/driver.h +++ b/src/driver.h @@ -717,6 +717,12 @@ typedef int virStreamPtr st, unsigned int flags); typedef int +(*virDrvDomainOpenChannel)(virDomainPtr dom, + const char *name, + virStreamPtr st, + unsigned int flags); + +typedef int (*virDrvDomainOpenGraphics)(virDomainPtr dom, unsigned int idx, int fd, @@ -1078,6 +1084,7 @@ struct _virDriver { virDrvDomainQemuAttach qemuDomainAttach; virDrvDomainQemuAgentCommandqemuDomainArbitraryAgentCommand; virDrvDomainOpenConsole domainOpenConsole; +virDrvDomainOpenChannel domainOpenChannel; virDrvDomainOpenGraphicsdomainOpenGraphics; virDrvDomainInjectNMI domainInjectNMI; virDrvDomainMigrateBegin3 domainMigrateBegin3; diff --git a/src/libvirt.c b/src/libvirt.c index bf674d1..6d1da12 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -19118,6 +19118,67 @@ error: } /** + * virDomainOpenChannel: + * @dom: a domain object + * @name: the channel name, or NULL + * @st: a stream to associate with the channel + * @flags: bitwise-OR of virDomainChannelFlags + * + * This opens the host interface associated with a channel device on a + * guest, if the host interface is supported. If @name is given, it + * can match either the device alias (e.g. channel0), or the virtio + * target name (e.g. org.qemu.guest_agent.0). If @name is omitted, + * then the first channel is opened. The channel is associated with + * the passed in @st stream, which should have been opened in + * non-blocking mode for bi-directional I/O. + * + * By default, when @flags is 0, the open will fail if libvirt detects + * that the channel is already in use by another client; passing + * VIR_DOMAIN_CHANNEL_FORCE will cause libvirt to forcefully remove the + * other client prior to opening this channel. + * + * Returns 0 if the channel was opened, -1 on error + */ +int virDomainOpenChannel(virDomainPtr dom, + const char *name, + virStreamPtr st, + unsigned int flags) +{ +virConnectPtr conn; + +VIR_DOMAIN_DEBUG(dom, name=%s, st=%p, flags=%x, + NULLSTR(name), st, flags); + +virResetLastError(); + +if (!VIR_IS_DOMAIN(dom)) { +virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); +virDispatchError(NULL); +return -1; +} + +conn = dom-conn; +if (conn-flags VIR_CONNECT_RO) { +virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); +goto error; +} + +if (conn-driver-domainOpenChannel) { +int ret; +ret = conn-driver-domainOpenChannel(dom, name, st, flags); +if (ret 0) +goto error; +return ret; +} + +virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: +virDispatchError(conn); +return -1; +} + +/** * virDomainBlockJobAbort: * @dom: pointer to domain object * @disk: path to the block device, or device shorthand diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index
[libvirt] [PATCHv2 2/5] conf: Rename virconsole.* to virchrdev.*
This is just code motion, in preparation to rename identifiers to be less console-specific. --- po/POTFILES.in | 2 +- src/Makefile.am | 2 +- src/conf/virchrdev.c | 414 +++ src/conf/virchrdev.h | 36 + src/conf/virconsole.c| 414 --- src/conf/virconsole.h| 36 - src/libvirt_private.syms | 2 +- src/qemu/qemu_domain.h | 2 +- 8 files changed, 454 insertions(+), 454 deletions(-) create mode 100644 src/conf/virchrdev.c create mode 100644 src/conf/virchrdev.h delete mode 100644 src/conf/virconsole.c delete mode 100644 src/conf/virconsole.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 4d94799..95619f9 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -22,7 +22,7 @@ src/conf/secret_conf.c src/conf/snapshot_conf.c src/conf/storage_conf.c src/conf/storage_encryption_conf.c -src/conf/virconsole.c +src/conf/virchrdev.c src/cpu/cpu.c src/cpu/cpu_generic.c src/cpu/cpu_map.c diff --git a/src/Makefile.am b/src/Makefile.am index f7a9b91..02bf47d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -246,7 +246,7 @@ CPU_CONF_SOURCES = \ # Safe console handling helper APIs CONSOLE_CONF_SOURCES = \ - conf/virconsole.c conf/virconsole.h + conf/virchrdev.c conf/virchrdev.h # Device Helper APIs DEVICE_CONF_SOURCES = \ diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c new file mode 100644 index 000..7b471ae --- /dev/null +++ b/src/conf/virchrdev.c @@ -0,0 +1,414 @@ +/** + * virchrdev.c: api to guarantee mutually exclusive + * access to domain's consoles + * + * Copyright (C) 2011-2012 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * http://www.gnu.org/licenses/. + * + * Author: Peter Krempa pkre...@redhat.com + */ + +#include config.h + +#include fcntl.h +#include unistd.h +#include sys/types.h + +#include virchrdev.h +#include virhash.h +#include fdstream.h +#include internal.h +#include virthread.h +#include viralloc.h +#include virpidfile.h +#include virlog.h +#include virerror.h +#include virfile.h + +#define VIR_FROM_THIS VIR_FROM_NONE + +/* structure holding information about consoles + * open in a given domain */ +struct _virConsoles { +virMutex lock; +virHashTablePtr hash; +}; + +typedef struct _virConsoleStreamInfo virConsoleStreamInfo; +typedef virConsoleStreamInfo *virConsoleStreamInfoPtr; +struct _virConsoleStreamInfo { +virConsolesPtr cons; +const char *pty; +}; + +#ifdef VIR_PTY_LOCK_FILE_PATH +/** + * Create a full filename with path to the lock file based on + * name/path of corresponding pty + * + * @pty path of the console device + * + * Returns a modified name that the caller has to free, or NULL + * on error. + */ +static char *virConsoleLockFilePath(const char *pty) +{ +char *path = NULL; +char *sanitizedPath = NULL; +char *ptyCopy; +char *filename; +char *p; + +if (!(ptyCopy = strdup(pty))) { +virReportOOMError(); +goto cleanup; +} + +/* skip the leading /dev/ */ +filename = STRSKIP(ptyCopy, /dev); +if (!filename) +filename = ptyCopy; + +/* substitute path forward slashes for underscores */ +p = filename; +while (*p) { +if (*p == '/') +*p = '_'; +++p; +} + +if (virAsprintf(path, %s/LCK..%s, VIR_PTY_LOCK_FILE_PATH, filename) 0) +goto cleanup; + +sanitizedPath = virFileSanitizePath(path); + +cleanup: +VIR_FREE(path); +VIR_FREE(ptyCopy); + +return sanitizedPath; +} + +/** + * Verify and create a lock file for a console pty + * + * @pty Path of the console device + * + * Returns 0 on success, -1 on error + */ +static int virConsoleLockFileCreate(const char *pty) +{ +char *path = NULL; +int ret = -1; +int lockfd = -1; +char *pidStr = NULL; +pid_t pid; + +/* build lock file path */ +if (!(path = virConsoleLockFilePath(pty))) +goto cleanup; + +/* check if a log file and process holding the lock still exists */ +if (virPidFileReadPathIfAlive(path, pid, NULL) == 0 pid = 0) { +/* the process exists, the lockfile is valid */ +virReportError(VIR_ERR_OPERATION_FAILED,
[libvirt] [PATCHv2 3/5] conf: Rename console-specific identifiers to be more generic
The functionality provided in virchrdev.c (previously virconsole.c) is applicable to other types of character devices besides consoles, such as channels. This patch is just code motion, renaming things such as console or pty, instead using more general terms such as character device or device path. --- configure.ac | 48 +-- src/Makefile.am | 6 +- src/conf/virchrdev.c | 220 +++ src/conf/virchrdev.h | 18 ++-- src/libvirt_private.syms | 6 +- src/qemu/qemu_domain.c | 4 +- src/qemu/qemu_domain.h | 2 +- src/qemu/qemu_driver.c | 8 +- 8 files changed, 156 insertions(+), 156 deletions(-) diff --git a/configure.ac b/configure.ac index 3c97e4f..0f5d455 100644 --- a/configure.ac +++ b/configure.ac @@ -426,12 +426,12 @@ AC_ARG_WITH([remote], AC_HELP_STRING([--with-remote], [add remote driver support @:@default=yes@:@]),[],[with_remote=yes]) AC_ARG_WITH([libvirtd], AC_HELP_STRING([--with-libvirtd], [add libvirtd support @:@default=yes@:@]),[],[with_libvirtd=yes]) -AC_ARG_WITH([console-lock-files], - AC_HELP_STRING([--with-console-lock-files], - [location for UUCP style lock files for console PTYs +AC_ARG_WITH([chrdev-lock-files], + AC_HELP_STRING([--with-chrdev-lock-files], + [location for UUCP style lock files for character devices (use auto for default paths on some platforms) @:@default=auto@:@]), - [],[with_console_lock_files=auto]) + [],[with_chrdev_lock_files=auto]) AC_ARG_WITH([libssh2_transport], AC_HELP_STRING([--with-libssh2_transport], [libssh2 location @:@default=check@:@]),[],[with_libssh2_transport=check]) @@ -1431,25 +1431,25 @@ AM_CONDITIONAL([HAVE_AUDIT], [test $with_audit = yes]) AC_SUBST([AUDIT_CFLAGS]) AC_SUBST([AUDIT_LIBS]) -dnl UUCP style file locks for PTY consoles -if test $with_console_lock_files != no; then - case $with_console_lock_files in +dnl UUCP style file locks for character devices +if test $with_chrdev_lock_files != no; then + case $with_chrdev_lock_files in yes | auto) dnl Default locations for platforms, or disable if unknown if test $with_linux = yes; then - with_console_lock_files=/var/lock -elif test $with_console_lock_files = auto; then - with_console_lock_files=no + with_chrdev_lock_files=/var/lock +elif test $with_chrdev_lock_files = auto; then + with_chrdev_lock_files=no fi ;; esac - if test $with_console_lock_files = yes; then + if test $with_chrdev_lock_files = yes; then AC_MSG_ERROR([You must specify path for the lock files on this platform]) fi - AC_DEFINE_UNQUOTED([VIR_PTY_LOCK_FILE_PATH], $with_console_lock_files, - [path to directory containing UUCP pty lock files]) + AC_DEFINE_UNQUOTED([VIR_CHRDEV_LOCK_FILE_PATH], $with_chrdev_lock_files, + [path to directory containing UUCP device lock files]) fi -AM_CONDITIONAL([VIR_PTY_LOCK_FILE_PATH], [test $with_console_lock_files != no]) +AM_CONDITIONAL([VIR_CHRDEV_LOCK_FILE_PATH], [test $with_chrdev_lock_files != no]) dnl SELinux @@ -3287,16 +3287,16 @@ AC_MSG_NOTICE([ Alloc OOM: $enable_oom]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([Miscellaneous]) AC_MSG_NOTICE([]) -AC_MSG_NOTICE([Debug: $enable_debug]) -AC_MSG_NOTICE([ Use -Werror: $set_werror]) -AC_MSG_NOTICE([Warning Flags: $WARN_CFLAGS]) -AC_MSG_NOTICE([ Readline: $lv_use_readline]) -AC_MSG_NOTICE([ Python: $with_python]) -AC_MSG_NOTICE([ DTrace: $with_dtrace]) -AC_MSG_NOTICE([numad: $with_numad]) -AC_MSG_NOTICE([ XML Catalog: $XML_CATALOG_FILE]) -AC_MSG_NOTICE([ Init script: $with_init_script]) -AC_MSG_NOTICE([Console locks: $with_console_lock_files]) +AC_MSG_NOTICE([Debug: $enable_debug]) +AC_MSG_NOTICE([ Use -Werror: $set_werror]) +AC_MSG_NOTICE([Warning Flags: $WARN_CFLAGS]) +AC_MSG_NOTICE([ Readline: $lv_use_readline]) +AC_MSG_NOTICE([ Python: $with_python]) +AC_MSG_NOTICE([ DTrace: $with_dtrace]) +AC_MSG_NOTICE([numad: $with_numad]) +AC_MSG_NOTICE([ XML Catalog: $XML_CATALOG_FILE]) +AC_MSG_NOTICE([ Init script: $with_init_script]) +AC_MSG_NOTICE([Char device locks: $with_chrdev_lock_files]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([Privileges]) AC_MSG_NOTICE([]) diff --git a/src/Makefile.am b/src/Makefile.am index 02bf47d..194a7a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -244,8 +244,8 @@ ENCRYPTION_CONF_SOURCES = \ CPU_CONF_SOURCES = \ conf/cpu_conf.c conf/cpu_conf.h -# Safe console handling helper APIs -CONSOLE_CONF_SOURCES = \ +# Safe character device handling helper APIs +CHRDEV_CONF_SOURCES = \ conf/virchrdev.c conf/virchrdev.h # Device Helper APIs
[libvirt] [PATCHv2 5/5] qemu: Implement virDomainOpenChannel API
--- v2: correct version comment to 1.0.2 src/qemu/qemu_driver.c | 73 ++ 1 file changed, 73 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 20e2001..cdbe30d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12593,6 +12593,78 @@ cleanup: return ret; } +static int +qemuDomainOpenChannel(virDomainPtr dom, + const char *name, + virStreamPtr st, + unsigned int flags) +{ +virDomainObjPtr vm = NULL; +int ret = -1; +int i; +virDomainChrDefPtr chr = NULL; +qemuDomainObjPrivatePtr priv; + +virCheckFlags(VIR_DOMAIN_CHANNEL_FORCE, -1); + +if (!(vm = qemuDomObjFromDomain(dom))) +goto cleanup; + +if (!virDomainObjIsActive(vm)) { +virReportError(VIR_ERR_OPERATION_INVALID, + %s, _(domain is not running)); +goto cleanup; +} + +priv = vm-privateData; + +if (name) { +for (i = 0 ; !chr i vm-def-nchannels ; i++) { +if (STREQ(name, vm-def-channels[i]-info.alias)) +chr = vm-def-channels[i]; + +if (vm-def-channels[i]-targetType == \ +VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO +STREQ(name, vm-def-channels[i]-target.name)) +chr = vm-def-channels[i]; +} +} else { +if (vm-def-nchannels) +chr = vm-def-channels[0]; +} + +if (!chr) { +virReportError(VIR_ERR_INTERNAL_ERROR, + _(cannot find channel %s), + NULLSTR(name)); +goto cleanup; +} + +if (chr-source.type != VIR_DOMAIN_CHR_TYPE_UNIX) { +virReportError(VIR_ERR_INTERNAL_ERROR, + _(channel %s is not using a UNIX socket), + NULLSTR(name)); +goto cleanup; +} + +/* handle mutually exclusive access to channel devices */ +ret = virChrdevOpen(priv-devs, +chr-source, +st, +(flags VIR_DOMAIN_CHANNEL_FORCE) != 0); + +if (ret == 1) { +virReportError(VIR_ERR_OPERATION_FAILED, %s, + _(Active channel stream exists for this domain)); +ret = -1; +} + +cleanup: +if (vm) +virDomainObjUnlock(vm); +return ret; +} + static char * qemuDiskPathToAlias(virDomainObjPtr vm, const char *path, int *idx) { @@ -14694,6 +14766,7 @@ static virDriver qemuDriver = { .nodeSetMemoryParameters = nodeSetMemoryParameters, /* 0.10.2 */ .nodeGetCPUMap = nodeGetCPUMap, /* 1.0.0 */ .domainFSTrim = qemuDomainFSTrim, /* 1.0.1 */ +.domainOpenChannel = qemuDomainOpenChannel, /* 1.0.2 */ }; -- 1.7.11.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv2 0/5] Add API to tunnel channels
This series enables the qemu driver to tunnel a virtio channel. This is useful for a remote session to communicate with a guest channel via the streaming API. This was originally fleshed out a while back in this thread: https://www.redhat.com/archives/libvir-list/2011-September/msg01049.html This implements only item (3) in that list. The new API is nearly identical to the existing virDomainOpenConsole API, except it works on channels, and supports UNIX sockets in addition to PTYs for channel source type. This is my first libvirt patch, please be gentle :) --- v2: - Rebased against master - Correct version to 1.0.2 in 5/5 --- John Eckersberg (5): api: Add API to tunnel a guest channel via stream conf: Rename virconsole.* to virchrdev.* conf: Rename console-specific identifiers to be more generic conf: Add unix socket support to virChrdevOpen qemu: Implement virDomainOpenChannel API configure.ac | 48 ++--- include/libvirt/libvirt.h.in | 16 ++ po/POTFILES.in | 2 +- src/Makefile.am | 8 +- src/conf/virchrdev.c | 442 +++ src/conf/virchrdev.h | 37 src/conf/virconsole.c| 414 src/conf/virconsole.h| 36 src/driver.h | 7 + src/libvirt.c| 61 ++ src/libvirt_private.syms | 8 +- src/libvirt_public.syms | 5 + src/qemu/qemu_domain.c | 4 +- src/qemu/qemu_domain.h | 4 +- src/qemu/qemu_driver.c | 81 +++- src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 9 +- src/remote_protocol-structs | 6 + 18 files changed, 697 insertions(+), 492 deletions(-) create mode 100644 src/conf/virchrdev.c create mode 100644 src/conf/virchrdev.h delete mode 100644 src/conf/virconsole.c delete mode 100644 src/conf/virconsole.h -- 1.7.11.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv2 4/5] conf: Add unix socket support to virChrdevOpen
This also changes the function signature to take a virDomainChrSourceDefPtr instead of just a path, since it needs to differentiate behavior based on source-type. --- src/conf/virchrdev.c | 38 +- src/conf/virchrdev.h | 5 +++-- src/qemu/qemu_driver.c | 2 +- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index dcb064f..1802324 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -324,7 +324,7 @@ void virChrdevFree(virChrdevsPtr devs) * same FD by two processes. * * @devs Pointer to private structure holding data about device streams. - * @path Path to the character device to be opened. + * @source Pointer to private structure holding data about device source. * @st Stream the client wishes to use for the device connection. * @force On true, close active device streams for the selected character *device before opening this connection. @@ -334,14 +334,29 @@ void virChrdevFree(virChrdevsPtr devs) * error and 1 if the device stream is open and busy. */ int virChrdevOpen(virChrdevsPtr devs, - const char *path, - virStreamPtr st, - bool force) + virDomainChrSourceDefPtr source, + virStreamPtr st, + bool force) { virChrdevStreamInfoPtr cbdata = NULL; virStreamPtr savedStream; +const char *path; int ret; +switch (source-type) { +case VIR_DOMAIN_CHR_TYPE_PTY: +path = source-data.file.path; +break; +case VIR_DOMAIN_CHR_TYPE_UNIX: +path = source-data.nix.path; +break; +default: +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(Unsupported device type '%s'), + virDomainChrTypeToString(source-type)); +return -1; +} + virMutexLock(devs-lock); if ((savedStream = virHashLookup(devs-hash, path))) { @@ -391,8 +406,21 @@ int virChrdevOpen(virChrdevsPtr devs, } /* open the character device */ -if (virFDStreamOpenFile(st, path, 0, 0, O_RDWR) 0) +switch (source-type) { +case VIR_DOMAIN_CHR_TYPE_PTY: +if (virFDStreamOpenFile(st, path, 0, 0, O_RDWR) 0) +goto error; +break; +case VIR_DOMAIN_CHR_TYPE_UNIX: +if (virFDStreamConnectUNIX(st, path, false) 0) +goto error; +break; +default: +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(Unsupported device type '%s'), + virDomainChrTypeToString(source-type)); goto error; +} /* add cleanup callback */ virFDStreamSetInternalCloseCb(st, diff --git a/src/conf/virchrdev.h b/src/conf/virchrdev.h index 57d7576..e1990e8 100644 --- a/src/conf/virchrdev.h +++ b/src/conf/virchrdev.h @@ -24,6 +24,7 @@ # define __VIR_CHRDEV_H__ # include internal.h +# include domain_conf.h typedef struct _virChrdevs virChrdevs; typedef virChrdevs *virChrdevsPtr; @@ -31,6 +32,6 @@ typedef virChrdevs *virChrdevsPtr; virChrdevsPtr virChrdevAlloc(void); void virChrdevFree(virChrdevsPtr devs); -int virChrdevOpen(virChrdevsPtr devs, const char *path, - virStreamPtr st, bool force); +int virChrdevOpen(virChrdevsPtr devs, virDomainChrSourceDefPtr source, + virStreamPtr st, bool force); #endif /*__VIR_CHRDEV_H__*/ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 992af02..20e2001 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12577,7 +12577,7 @@ qemuDomainOpenConsole(virDomainPtr dom, /* handle mutually exclusive access to console devices */ ret = virChrdevOpen(priv-devs, -chr-source.data.file.path, +chr-source, st, (flags VIR_DOMAIN_CONSOLE_FORCE) != 0); -- 1.7.11.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] maint: update to latest gnulib
The update results in bootstrap being updated as well. --- .gnulib | 2 +- bootstrap | 15 --- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gnulib b/.gnulib index d245e6d..964bbc2 16 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit d245e6ddd6ab2624d0d83acd8f111454f984f50f +Subproject commit 964bbc2d419584e93fe629ddbc40595612f62083 diff --git a/bootstrap b/bootstrap index e3e270b..c84d249 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,6 @@ #! /bin/sh # Print a version string. -scriptversion=2012-07-19.14; # UTC +scriptversion=2012-12-28.10; # UTC # Bootstrap this package from checked-out sources. @@ -889,20 +889,21 @@ find $m4_base $source_base \ -depth \( -name '*.m4' -o -name '*.[ch]' \) \ -type l -xtype l -delete /dev/null 21 +# Invoke autoreconf with --force --install to ensure upgrades of tools +# such as ylwrap. +AUTORECONFFLAGS=--verbose --install --force -I $m4_base $ACLOCAL_FLAGS + # Some systems (RHEL 5) are using ancient autotools, for which the # --no-recursive option had not been invented. Detect that lack and # omit the option when it's not supported. FIXME in 2017: remove this # hack when RHEL 5 autotools are updated, or when they become irrelevant. -no_recursive= case $($AUTORECONF --help) in - *--no-recursive*) no_recursive=--no-recursive;; + *--no-recursive*) AUTORECONFFLAGS=$AUTORECONFFLAGS --no-recursive;; esac # Tell autoreconf not to invoke autopoint or libtoolize; they were run above. -echo running: AUTOPOINT=true LIBTOOLIZE=true \ -$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS -AUTOPOINT=true LIBTOOLIZE=true \ -$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \ +echo running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS +AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \ || die autoreconf failed # Get some extra files from gnulib, overriding existing files. -- 1.8.0.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] maint: update to latest gnulib
On 01/02/2013 08:39 AM, Michal Privoznik wrote: The update results in bootstrap being updated as well. --- .gnulib | 2 +- bootstrap | 15 --- 2 files changed, 9 insertions(+), 8 deletions(-) Phooey, when trying this, I see: configure.ac:126: warning: gl_INLINE is m4_require'd but not m4_defun'd gnulib/m4/xalloc.m4:14: gl_PREREQ_XALLOC is expanded from... gnulib/m4/xalloc.m4:7: gl_XALLOC is expanded from... gnulib/m4/gnulib-comp.m4:501: gl_INIT is expanded from... configure.ac:126: the top level which looks like a gnulib bug. I'm investigating what it would take to fix gnulib; but agree that we need something soon to fix the 'make syntax-check' failures now that gnulib has changed copyright year to 2013. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] maint: update to latest gnulib
'make syntax-check' warned that gnulib's copyright is now out of date. * .gnulib: Update to latest, for copyright year bump. * gnulib/local/m4/ssize_t.m4.diff: Regenerate. * bootstrap: Synchronize from upstream. --- configure.ac:126: warning: gl_INLINE is m4_require'd but not m4_defun'd Turns out it wasn't an upstream gnulib problem, but a problem with our gnulib-local patch not applying which in turn killed gnulib-tool and failed to pull in the needed updates. I'm pushing this under the build-breaker rule. .gnulib | 2 +- bootstrap | 17 + gnulib/local/m4/ssize_t.m4.diff | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gnulib b/.gnulib index d245e6d..964bbc2 16 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit d245e6ddd6ab2624d0d83acd8f111454f984f50f +Subproject commit 964bbc2d419584e93fe629ddbc40595612f62083 diff --git a/bootstrap b/bootstrap index e3e270b..012907a 100755 --- a/bootstrap +++ b/bootstrap @@ -1,10 +1,10 @@ #! /bin/sh # Print a version string. -scriptversion=2012-07-19.14; # UTC +scriptversion=2012-12-28.10; # UTC # Bootstrap this package from checked-out sources. -# Copyright (C) 2003-2012 Free Software Foundation, Inc. +# Copyright (C) 2003-2013 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -889,20 +889,21 @@ find $m4_base $source_base \ -depth \( -name '*.m4' -o -name '*.[ch]' \) \ -type l -xtype l -delete /dev/null 21 +# Invoke autoreconf with --force --install to ensure upgrades of tools +# such as ylwrap. +AUTORECONFFLAGS=--verbose --install --force -I $m4_base $ACLOCAL_FLAGS + # Some systems (RHEL 5) are using ancient autotools, for which the # --no-recursive option had not been invented. Detect that lack and # omit the option when it's not supported. FIXME in 2017: remove this # hack when RHEL 5 autotools are updated, or when they become irrelevant. -no_recursive= case $($AUTORECONF --help) in - *--no-recursive*) no_recursive=--no-recursive;; + *--no-recursive*) AUTORECONFFLAGS=$AUTORECONFFLAGS --no-recursive;; esac # Tell autoreconf not to invoke autopoint or libtoolize; they were run above. -echo running: AUTOPOINT=true LIBTOOLIZE=true \ -$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS -AUTOPOINT=true LIBTOOLIZE=true \ -$AUTORECONF --verbose --install $no_recursive -I $m4_base $ACLOCAL_FLAGS \ +echo running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS +AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \ || die autoreconf failed # Get some extra files from gnulib, overriding existing files. diff --git a/gnulib/local/m4/ssize_t.m4.diff b/gnulib/local/m4/ssize_t.m4.diff index d0ae286..93f8ad7 100644 --- a/gnulib/local/m4/ssize_t.m4.diff +++ b/gnulib/local/m4/ssize_t.m4.diff @@ -5,7 +5,7 @@ index 209d64c..5ea72a1 100644 @@ -1,4 +1,4 @@ -# ssize_t.m4 serial 5 (gettext-0.18.2) +# ssize_t.m4 serial 6 (gettext-0.18.2) - dnl Copyright (C) 2001-2003, 2006, 2010-2012 Free Software Foundation, Inc. + dnl Copyright (C) 2001-2003, 2006, 2010-2013 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,21 @@ AC_DEFUN([gt_TYPE_SSIZE_T], -- 1.8.0.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Build failed in Jenkins: libvirt-build #472
See http://honk.sigxcpu.org:8001/job/libvirt-build/472/changes Changes: [eblake] maint: update to latest gnulib -- [...truncated 5806 lines...] GENwchar.h GENwctype.h make all-am make[3]: Entering directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/gnulib/lib' CC allocator.lo CC areadlink.lo CC base64.lo CC binary-io.lo CC bitrotate.lo CC c-ctype.lo CC c-strcasecmp.lo CC c-strncasecmp.lo CC c-strcasestr.lo CC careadlinkat.lo CC cloexec.lo CC count-one-bits.lo CC md5.lo CC sha256.lo CC dirname-lgpl.lo CC basename-lgpl.lo CC stripslash.lo CC fd-hook.lo CC freading.lo CC localcharset.lo CC lock.lo CC malloca.lo CC nonblocking.lo CC passfd.lo CC physmem.lo CC pipe2.lo CC sig-handler.lo CC sockets.lo CC stat-time.lo CC stdio.lo CC strnlen1.lo CC sys_socket.lo CC tempname.lo CC threadlib.lo CC unistd.lo CC wctype-h.lo CC xsize.lo CC asnprintf.lo CC fclose.lo CC fcntl.lo CC fflush.lo CC fpurge.lo CC fseek.lo CC fseeko.lo CC ioctl.lo CC mktime.lo CC perror.lo CC printf-args.lo CC printf-parse.lo CC strerror.lo CC strerror_r.lo CC vasnprintf.lo CCLD libgnu.la GENcharset.alias GENref-add.sed GENref-del.sed make[3]: Leaving directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/gnulib/lib' make[2]: Leaving directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/gnulib/lib' Making all in include make[2]: Entering directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/include' Making all in libvirt make[3]: Entering directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/include/libvirt' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/include/libvirt' make[3]: Entering directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/include' make[3]: Nothing to be done for `all-am'. make[3]: Leaving directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/include' make[2]: Leaving directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/include' Making all in src make[2]: Entering directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/src' GENlibvirt.syms GENlibvirt.def make all-am make[3]: Entering directory `http://honk.sigxcpu.org:8001/job/libvirt-build/ws/src' CC libvirt_util_la-viralloc.lo CC libvirt_util_la-virarch.lo CC libvirt_util_la-viratomic.lo CC libvirt_util_la-viraudit.lo CC libvirt_util_la-virauth.lo CC libvirt_util_la-virauthconfig.lo CC libvirt_util_la-virbitmap.lo CC libvirt_util_la-virbuffer.lo CC libvirt_util_la-vircgroup.lo CC libvirt_util_la-vircommand.lo CC libvirt_util_la-virconf.lo CC libvirt_util_la-virdbus.lo CC libvirt_util_la-virdnsmasq.lo CC libvirt_util_la-virebtables.lo CC libvirt_util_la-virerror.lo CC libvirt_util_la-virevent.lo CC libvirt_util_la-vireventpoll.lo CC libvirt_util_la-virfile.lo CC libvirt_util_la-virhash.lo CC libvirt_util_la-virhashcode.lo CC libvirt_util_la-virhook.lo CC libvirt_util_la-virinitctl.lo CC libvirt_util_la-viriptables.lo CC libvirt_util_la-virjson.lo CC libvirt_util_la-virkeycode.lo CC libvirt_util_la-virkeyfile.lo CC libvirt_util_la-virlockspace.lo CC libvirt_util_la-virlog.lo CC libvirt_util_la-virmacaddr.lo CC libvirt_util_la-virnetdev.lo CC libvirt_util_la-virnetdevbandwidth.lo CC libvirt_util_la-virnetdevbridge.lo CC libvirt_util_la-virnetdevmacvlan.lo CC libvirt_util_la-virnetdevopenvswitch.lo CC libvirt_util_la-virnetdevtap.lo CC libvirt_util_la-virnetdevveth.lo CC libvirt_util_la-virnetdevvlan.lo CC libvirt_util_la-virnetdevvportprofile.lo CC libvirt_util_la-virnetlink.lo CC libvirt_util_la-virnodesuspend.lo CC libvirt_util_la-virobject.lo CC libvirt_util_la-virpci.lo CC libvirt_util_la-virpidfile.lo CC libvirt_util_la-virprocess.lo CC libvirt_util_la-virrandom.lo CC libvirt_util_la-virsexpr.lo CC libvirt_util_la-virsocketaddr.lo CC libvirt_util_la-virstatslinux.lo CC libvirt_util_la-virstoragefile.lo CC libvirt_util_la-virstring.lo CC libvirt_util_la-virsysinfo.lo CC libvirt_util_la-virthread.lo CC libvirt_util_la-virthreadpool.lo CC libvirt_util_la-virtime.lo CC libvirt_util_la-virtypedparam.lo CC libvirt_util_la-virusb.lo CC libvirt_util_la-viruri.lo CC libvirt_util_la-virutil.lo CC libvirt_util_la-viruuid.lo CC libvirt_util_la-virxml.lo CCLD libvirt_util.la CC
Re: [libvirt] [PATCH] qemu: Don't parse log output when starting up a domain
On 01/02/2013 08:23 AM, Michal Privoznik wrote: Despite our great effort we still parsed qemu log output. We wouldn't notice unless qemu changed the format of the logs slightly. Maybe mention that the upcoming qemu 1.4 does just that. Anyway, now we should gather all interesting knobs like pty paths from monitor. Moreover, since for historical reasons the first console can be just an alias to the first serial port, we need to check this and copy the pty path if that's the case to the first console. --- src/qemu/qemu_capabilities.c | 7 +++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_process.c | 20 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) ACK, with a grammar nit. @@ -1544,8 +1545,23 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm, if (qemuProcessLookupPTYs(vm-def-channels, vm-def-nchannels, paths, chardevfmt) 0) return -1; +/* For historical reasons, console[0] can be just an alias + * for serial[0]; That's why we need to update it as well */ Either you are starting a new sentence and need a full stop (serial[0]. That's), or you don't need a capital after semicolon (serial[0]; that's). Also, s/well/well./ wouldn't hurt. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Build failed in Jenkins: libvirt-build #472
On 01/02/2013 10:29 AM, Jenkins CI wrote: See http://honk.sigxcpu.org:8001/job/libvirt-build/472/changes Changes: [eblake] maint: update to latest gnulib CCLD libvirt_security_manager.la CCLD libvirt.la ./.libs/libvirt_util.a(libvirt_util_la-virnetdevtap.o): In function `rpl_fwrite': http://honk.sigxcpu.org:8001/job/libvirt-build/ws/src/../gnulib/lib/stdio.h:903: multiple definition of `rpl_fwrite' ./.libs/libvirt_util.a(libvirt_util_la-virnetdev.o):http://honk.sigxcpu.org:8001/job/libvirt-build/ws/src/../gnulib/lb/stdio.h:903: first defined here Yuck. This sounds like an issue in upstream gnulib inline handling. I see this from your logs: checking build system type... i686-pc-linux-gnu but that doesn't tell me what version of glibc and gcc you are using, in case the problem is an interaction between those (as is, I recently reported[1] a case where a mismatch of old glibc and new gcc causes build failures, but that was on a modified RHEL 5 box, so probably doesn't match your setup). [1] https://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00176.html I haven't been able to reproduce the failure locally on any of my Fedora or RHEL boxes, using incremental builds; I am also in the middle of trying a fresh clone build, to see if that is any different. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] build: use autobuild module to make build logs nicer
A recent build failure made me realize that we could usefully add a bit more information to configure output, for aid in analysis of failed builds. Pulling in the autobuild module merely adds these four lines to configure output: configure: autobuild project... libvirt configure: autobuild revision... 1.0.1 configure: autobuild hostname... myhost configure: autobuild timestamp... 20130102T181342Z which can be useful even if not using the Autobuild project to parse build logs. * bootstrap.conf (gnulib_modules): Add autobuild. --- I'll wait for a review on this one. Hmm, I also realized that there are other things that might be useful for autobuild to log, such as uname output; I'll ask upstream if it is worth enhancing the autobuild output, and if upstream agrees, then we would pick up that enhanced information next time we sync from gnulib. bootstrap.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bootstrap.conf b/bootstrap.conf index 37a0ae1..4b45a4f 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -1,6 +1,6 @@ # Bootstrap configuration. -# Copyright (C) 2010-2012 Red Hat, Inc. +# Copyright (C) 2010-2013 Red Hat, Inc. # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -20,6 +20,7 @@ gnulib_modules=' accept areadlink +autobuild base64 bind bitrotate -- 1.8.0.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: use autobuild module to make build logs nicer
On Wed, Jan 02, 2013 at 11:26:18AM -0700, Eric Blake wrote: A recent build failure made me realize that we could usefully add a bit more information to configure output, for aid in analysis of failed builds. Pulling in the autobuild module merely adds these four lines to configure output: configure: autobuild project... libvirt configure: autobuild revision... 1.0.1 configure: autobuild hostname... myhost configure: autobuild timestamp... 20130102T181342Z which can be useful even if not using the Autobuild project to parse build logs. * bootstrap.conf (gnulib_modules): Add autobuild. --- I'll wait for a review on this one. Hmm, I also realized that there are other things that might be useful for autobuild to log, such as uname output; I'll ask upstream if it is worth enhancing the autobuild output, and if upstream agrees, then we would pick up that enhanced information next time we sync from gnulib. I'd suggest the GIT head hash be added too. bootstrap.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: use autobuild module to make build logs nicer
On 01/02/2013 11:39 AM, Daniel P. Berrange wrote: On Wed, Jan 02, 2013 at 11:26:18AM -0700, Eric Blake wrote: A recent build failure made me realize that we could usefully add a bit more information to configure output, for aid in analysis of failed builds. Pulling in the autobuild module merely adds these four lines to configure output: configure: autobuild project... libvirt configure: autobuild revision... 1.0.1 I'd suggest the GIT head hash be added too. Hmm, that would indeed be useful. It looks like it is as simple as modifying the shell variable AB_VERSION to contain more details, prior to invoking any gnulib macros; I'll play with a configure.ac patch appropriately, and post a v2 if I get it working. I'll wait for a review on this one. Hmm, I also realized that there are other things that might be useful for autobuild to log, such as uname output; I'll ask upstream if it is worth enhancing the autobuild output, and if upstream agrees, then we would pick up that enhanced information next time we sync from gnulib. Asked: http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/32280 bootstrap.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) ACK If I get to the end of the day without a v2, then I'll push this. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Coverity scan
On 12/20/2012 04:24 PM, Eric Blake wrote: On 12/20/2012 08:25 AM, John Ferlan wrote: First allow me to introduce myself - I'm John Ferlan a new Red Hat employee (3 weeks). I came from the closed world at HP where for the last 7 years I worked in a group developing/supporting HP's Integrity Virtual Machine software prior to it being outsourced to India this past May. I primarily worked in the CLI/API and daemon space, although I also spent quite a bit of time in the lower virtualization layers which mimicked the Integrity instructions. I am very happy to be in the open world and look forward to contributing. Everyone has to start some where. Welcome to libvirt! Based on recent list traffic, there are several people, not just John, and not just at Red Hat, that are aiming to provide initial contributions. Be sure to provide your feedback and questions on the list, and hopefully we can use that to make our hacking documentation even easier to follow for future newcomers. You may want to figure out why your mailer doesn't automatically wrap long lines. Webmail interfaces (gmail, zimbra) and Microsoft Exchange tend to be the worst mail agents when it comes to RFC compliance and lack of knobs to tune for improving the situation, which in turn can make it harder to read your messages and apply patches you submit. You may notice that many people on this list use mutt or Thunderbird rather than web mailers, if only to have better formatted mail, but it's not a hard pre-requisite (we won't reject a patch just because of how it was sent, although it might take longer to apply if we have to jump through hoops to get it extracted from the mail). For mailers that have the right knobs, turning on format=flowed is one way of sending reasonably formatted mail [but be aware that Thunderbird has had a rather nasty bug for several years now where defaulting to format=flowed can result in botching the whitespace of the quoted portion of a message you are replying to]. My first task here at Red Hat was to triage a Coverity scan executed against libvirt-1.0.0-1.fc19.src.rpm done in late November. There were 285 issues documented. I quickly found that some of the defects found there were already fixed in later submits upstream, so I ran a new Coverity scan last Friday and it came back with 297 issues broken down as follows: 1 ARRAY_VS_SINGLETON 33 BAD_SIZEOF 17 CHECKED_RETURN 1 CONSTANT_EXPRESSION_RESULT 5 COPY_PASTE_ERROR 13 DEADCODE 46 FORWARD_NULL 2 MISSING_RETURN 2 NEGATIVE_RETURNS 7 NULL_RETURNS 1 OVERRUN 137 RESOURCE_LEAK 18 REVERSE_INULL 1 SIGN_EXTENSION 3 UNINIT 8 UNUSED_VALUE 2 USE_AFTER_FREE Thanks for doing this. Helping to reduce the false positives and eliminate the real bugs will make it easier to run Coverity on a periodic basis and check for recent regressions while the code is still fresh on our minds. Looking forward to the patches you come up with. Ran a new scan recently - the number of defects increased slightly (+4 FORWARD_NULL, +2 MISSING_RETURN, and + 1 UNINIT). I worked my way through the entire list and just figured I'd start with an easier group for my first submit attempt. I have a series of relatively easy changes for the CHECKED_RETURN condition; however, I was hoping to perhaps get some feedback on two files which had more ramifications from just checking the return status. The first is 'src/phyp/phyp_driver.c'. Neither waitsocket() nor any of the callers check the return status. The implication being if select() fails the code will continue to wait. So is this desired? Conversely what are the ramifications of checking status on select() and using virReportSystemError()? Or perhaps some other way to log the failure? For any of the callers, any concerns over checking status return == -1 and jumping to the err label? I guess I'm concerned over making logic/flow changes to some long standing assumption. I've been on the opposite end of debugging one of those. The second is 'src/rpc/virnetsocket.c'. The Coverity complaint is that the setsockopt() call to set SO_REUSEADDR doesn't check the return status. I think this particular case may be a cut-n-paste type change as the from virNetSocketNewListenTCP(). Unless I'm missing something, does setting the reuse addr on a connect socket do anything? Can it just safely be removed? Tks, John -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Build failed in Jenkins: libvirt-build #472
Hi, On Wed, Jan 02, 2013 at 11:20:08AM -0700, Eric Blake wrote: On 01/02/2013 10:29 AM, Jenkins CI wrote: See http://honk.sigxcpu.org:8001/job/libvirt-build/472/changes Changes: [eblake] maint: update to latest gnulib CCLD libvirt_security_manager.la CCLD libvirt.la ./.libs/libvirt_util.a(libvirt_util_la-virnetdevtap.o): In function `rpl_fwrite': http://honk.sigxcpu.org:8001/job/libvirt-build/ws/src/../gnulib/lib/stdio.h:903: multiple definition of `rpl_fwrite' ./.libs/libvirt_util.a(libvirt_util_la-virnetdev.o):http://honk.sigxcpu.org:8001/job/libvirt-build/ws/src/../gnulib/lb/stdio.h:903: first defined here Yuck. This sounds like an issue in upstream gnulib inline handling. I see this from your logs: checking build system type... i686-pc-linux-gnu but that doesn't tell me what version of glibc and gcc you are using, in case the problem is an interaction between those (as is, I recently reported[1] a case where a mismatch of old glibc and new gcc causes build failures, but that was on a modified RHEL 5 box, so probably doesn't match your setup). [1] https://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00176.html This is gcc 4.7.1 and eglibc 2.13. I upgraded to Debian Wheezy's current gcc 4.7.2 without any changes. I'm not able to reproduce it locally on a Debian sid system either. I also tried a clean bootstrap http://honk.sigxcpu.org:8001/job/libvirt-build/474/ but the problem persists: $ nm src/.libs/libvirt_util.a | grep rpl_fwrite 0760 T rpl_fwrite T rpl_fwrite 0300 T rpl_fwrite Any information I can provide to diagnose this further? -- Guido P.S.: I've removed the mailing list from the build reports temporarily to not spam the list with new build failures until this is fixed. I haven't been able to reproduce the failure locally on any of my Fedora or RHEL boxes, using incremental builds; I am also in the middle of trying a fresh clone build, to see if that is any different. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] where is config.log when debugging a failure reported by Jenkins
Hello Jenkins folks, On the libvirt list, we came across a case where a broken commit was detected, but where the information available in the failure report was insufficient (for at least me) to reproduce the failure environment without asking more questions: http://honk.sigxcpu.org:8001/job/libvirt-build/472/ https://www.redhat.com/archives/libvir-list/2013-January/msg00037.html Is there any way that things can be tweaked to include the 'config.log' file in the web report of a failed build? Merely capturing the output of './configure' fails to provide some of the details that are intentionally redirected into the more verbose config.log file. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Build failed in Jenkins: libvirt-build #472
On 01/02/2013 01:14 PM, Guido Günther wrote: This is gcc 4.7.1 and eglibc 2.13. I upgraded to Debian Wheezy's current gcc 4.7.2 without any changes. I'm not able to reproduce it locally on a Debian sid system either. I also tried a clean bootstrap http://honk.sigxcpu.org:8001/job/libvirt-build/474/ but the problem persists: $ nm src/.libs/libvirt_util.a | grep rpl_fwrite 0760 T rpl_fwrite T rpl_fwrite 0300 T rpl_fwrite Any information I can provide to diagnose this further? Sure - can you paste the portion of libvirt/gnulib/lib/stdio.h that shows why rpl_fwrite was enabled in the first place? The original template file stdio.in.h looks like: #if @GNULIB_FWRITE@ # if @REPLACE_STDIO_WRITE_FUNCS@ (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) # if !(defined __cplusplus defined GNULIB_NAMESPACE) # undef fwrite # define fwrite rpl_fwrite # endif _GL_FUNCDECL_RPL (fwrite, size_t, On my F18 box, I see: #if 1 # if 0 (1 || 1) # if !(defined __cplusplus defined GNULIB_NAMESPACE) # undef fwrite # define fwrite rpl_fwrite # endif _GL_FUNCDECL_RPL (fwrite, size_t, which means that there is no replacement of stdio write functions on glibc; reading the source code of .gnulib/m4/stdio_h.m4, REPLACE_STDIO_WRITE_FUNCS is only set to 1 if gl_SIGNAL_SIGPIPE detects an unusual situation. So something in eglibc is tripping up gl_SIGNAL_SIGPIPE; maybe finding that portion of config.log will help understand root cause. Then again, your configure output shows: checking for SIGPIPE... yes which says gl_SIGNAL_SIGPIPE didn't find anything unusual. Oh, maybe the next culprit - I was compiling at -O0, which disables fortification (since that only works at -O1 or higher); in the gnulib stdio.h I see: /* Work around glibc bug 11959 http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959, which sometimes causes an unwanted diagnostic for fwrite calls. This affects only function declaration attributes, so it's not needed for C++. */ # if !defined __cplusplus 0 __USE_FORTIFY_LEVEL _GL_STDIO_INLINE size_t _GL_ARG_NONNULL ((1, 4)) rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream) { size_t r = fwrite (ptr, s, n, stream); (void) r; return r; } # undef fwrite # define fwrite rpl_fwrite # endif It could be that while this works for glibc, it causes grief on eglibc, especially depending on what _GL_STDIO_INLINE expands to at the time. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] where is config.log when debugging a failure reported by Jenkins
Hi Eric, On Wed, Jan 02, 2013 at 02:45:24PM -0700, Eric Blake wrote: Hello Jenkins folks, On the libvirt list, we came across a case where a broken commit was detected, but where the information available in the failure report was insufficient (for at least me) to reproduce the failure environment without asking more questions: http://honk.sigxcpu.org:8001/job/libvirt-build/472/ https://www.redhat.com/archives/libvir-list/2013-January/msg00037.html Is there any way that things can be tweaked to include the 'config.log' file in the web report of a failed build? Merely capturing the output of './configure' fails to provide some of the details that are intentionally redirected into the more verbose config.log file. Since the build job itself is a just a shell script I can cat that file to stdout in case of failure. I've changed the job to do so. Cheers, -- Guido -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] where is config.log when debugging a failure reported by Jenkins
On Wed, Jan 02, 2013 at 11:12:31PM +0100, Guido Günther wrote: Hi Eric, On Wed, Jan 02, 2013 at 02:45:24PM -0700, Eric Blake wrote: Hello Jenkins folks, On the libvirt list, we came across a case where a broken commit was detected, but where the information available in the failure report was insufficient (for at least me) to reproduce the failure environment without asking more questions: http://honk.sigxcpu.org:8001/job/libvirt-build/472/ https://www.redhat.com/archives/libvir-list/2013-January/msg00037.html Is there any way that things can be tweaked to include the 'config.log' file in the web report of a failed build? Merely capturing the output of './configure' fails to provide some of the details that are intentionally redirected into the more verbose config.log file. Since the build job itself is a just a shell script I can cat that file to stdout in case of failure. I've changed the job to do so. Even better: let's collect config.log as a build artifact so we have it for all builds and don't clutter up the build log itself. -- Guido -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCHv2] build: use autobuild module to make build logs nicer
A recent build failure made me realize that we could usefully add a bit more information to configure output, for aid in analysis of failed builds. Pulling in the autobuild module merely adds these four lines to configure output: configure: autobuild project... libvirt configure: autobuild revision... v1.0.1-113-g7a74eea configure: autobuild hostname... myhost configure: autobuild timestamp... 20130102T233543Z which can be useful even if not using the Autobuild project to parse build logs. * bootstrap.conf (gnulib_modules): Add autobuild. * configure.ac: Favor git version over release version, when available. --- The diff to v1 is the configure.ac changes to make the revision more useful; it seems harmless enough that I've gone ahead and pushed this based on Dan's ACK of v1. bootstrap.conf | 3 ++- configure.ac | 8 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 37a0ae1..4b45a4f 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -1,6 +1,6 @@ # Bootstrap configuration. -# Copyright (C) 2010-2012 Red Hat, Inc. +# Copyright (C) 2010-2013 Red Hat, Inc. # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -20,6 +20,7 @@ gnulib_modules=' accept areadlink +autobuild base64 bind bitrotate diff --git a/configure.ac b/configure.ac index 3c97e4f..d80cf8b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -dnl Copyright (C) 2005-2012 Red Hat, Inc. +dnl Copyright (C) 2005-2013 Red Hat, Inc. dnl See COPYING.LIB for the License of this software AC_INIT([libvirt], [1.0.1], [libvir-list@redhat.com], [], [http://libvirt.org]) @@ -122,6 +122,12 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_CPP +dnl Setting AB_VERSION makes the 'autobuild' lines of configure output +dnl slightly more useful +if test -d $srcdir/.git git --version /dev/null 21 ; then + AB_VERSION=`cd $srcdir git describe --match 'v[[0-9]]*' 2/dev/null` +fi + gl_EARLY gl_INIT -- 1.8.0.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Build failed in Jenkins: libvirt-build #472
[adding gnulib in cc] On 01/02/2013 03:03 PM, Eric Blake wrote: On 01/02/2013 01:14 PM, Guido Günther wrote: This is gcc 4.7.1 and eglibc 2.13. I upgraded to Debian Wheezy's current gcc 4.7.2 without any changes. I'm not able to reproduce it locally on a Debian sid system either. I also tried a clean bootstrap http://honk.sigxcpu.org:8001/job/libvirt-build/474/ but the problem persists: $ nm src/.libs/libvirt_util.a | grep rpl_fwrite 0760 T rpl_fwrite T rpl_fwrite 0300 T rpl_fwrite Any information I can provide to diagnose this further? Sure - can you paste the portion of libvirt/gnulib/lib/stdio.h that shows why rpl_fwrite was enabled in the first place? The original template file stdio.in.h looks like: #if @GNULIB_FWRITE@ # if @REPLACE_STDIO_WRITE_FUNCS@ (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@) # if !(defined __cplusplus defined GNULIB_NAMESPACE) # undef fwrite # define fwrite rpl_fwrite # endif _GL_FUNCDECL_RPL (fwrite, size_t, On my F18 box, I see: #if 1 # if 0 (1 || 1) # if !(defined __cplusplus defined GNULIB_NAMESPACE) # undef fwrite # define fwrite rpl_fwrite # endif _GL_FUNCDECL_RPL (fwrite, size_t, which means that there is no replacement of stdio write functions on glibc; reading the source code of .gnulib/m4/stdio_h.m4, REPLACE_STDIO_WRITE_FUNCS is only set to 1 if gl_SIGNAL_SIGPIPE detects an unusual situation. So something in eglibc is tripping up gl_SIGNAL_SIGPIPE; maybe finding that portion of config.log will help understand root cause. Then again, your configure output shows: checking for SIGPIPE... yes which says gl_SIGNAL_SIGPIPE didn't find anything unusual. Oh, maybe the next culprit - I was compiling at -O0, which disables fortification (since that only works at -O1 or higher); in the gnulib stdio.h I see: /* Work around glibc bug 11959 http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959, which sometimes causes an unwanted diagnostic for fwrite calls. This affects only function declaration attributes, so it's not needed for C++. */ # if !defined __cplusplus 0 __USE_FORTIFY_LEVEL _GL_STDIO_INLINE size_t _GL_ARG_NONNULL ((1, 4)) rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream) { size_t r = fwrite (ptr, s, n, stream); (void) r; return r; } # undef fwrite # define fwrite rpl_fwrite # endif It could be that while this works for glibc, it causes grief on eglibc, especially depending on what _GL_STDIO_INLINE expands to at the time. Aha, I reproduced the problem on glibc while using RHEL 6.3 and default CFLAGS (instead of my more typical CFLAGS=-g devel override). Definitely a problem in Paul's recent work on inline magic, where _GL_STDIO_INLINE is not doing the intended actions. Paul, any thoughts on what we need to do to fix this? Also, since that glibc bug (of a bogus __wur attribute on fwrite) has since been fixed, is the unconditional override to rpl_fwrite something that is still useful to keep around? -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/6] util: Prepare helpers for unpriv_sgio setting
On 01/02/2013 07:37 AM, Osier Yang wrote: virGetDeviceID could be used across the sources, but it doesn't relate with this series, and could be done later. * src/util/virutil.h: (Declare virGetDeviceID, and vir{Get,Set}DeviceUnprivSGIO) * src/util/virutil.c: (Implement virGetDeviceID and vir{Get,Set}DeviceUnprivSGIO) * src/libvirt_private.syms: Export private symbols of upper helpers --- src/libvirt_private.syms |3 + src/util/virutil.c | 140 ++ src/util/virutil.h | 11 3 files changed, 154 insertions(+), 0 deletions(-) ACK. +int +virSetDeviceUnprivSGIO(const char *path, + const char *sysfs_dir, + int unpriv_sgio) +{ +char *sysfs_path = NULL; +char *val = NULL; +int ret = -1; +int rc; + +if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir))) +return -1; + +if (!virFileExists(sysfs_path)) { +virReportError(VIR_ERR_OPERATION_INVALID, %s, + _(unpriv_sgio is not supported by this kernel)); +goto cleanup; If 'unpriv_sgio' is 0 here, does it make the logic in any later patches easier to return success in that case (you are setting things to the default)? But I'm okay with keeping it as a failure. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] RFC: An embedded mode for QEMU/LXC drivers
On Wed, Jan 02, 2013 at 03:36:54PM +, Daniel P. Berrange wrote: This is something I was thinking about a little over the christmas break. I've no intention of implementing this in the immediate future, but wanted to post it while it was fresh in my mind. Historically we have had 2 ways of using the stateful drivers like QEMU/LXC/UML/etc. - system mode - privileged libvirtd, one per host, started at boot - session mode - unprivileged libvirtd, one per non-root user, autostarted Within context of each daemon, VM name uniqueness is enforced. Operating via the daemon means that all applications connected to libvirtd get the same world view. This single world view is exactly what you want when dealing with server / cloud / desktop virtualization, because it means tools like 'virt-top', 'virt-viewer', 'virsh' can see the same VMs as virt-manager / oVirt / OpenStack / Boxes / etc. Recently we've seen increasing importance of a new use case which I will refer to as embedded virtualization. The best example of this use case is libguestfs which has long run a dedicated QEMU instance, but just now switched to using libvirtd. The other use case is virt-sandbox which is doing application confinement using LXC/KVM. In both these cases, operating via libvirtd is sub-optimal. Users of so called embedded virtualization, explicitly don't want to have interaction with other libvirt applications. They likely don't even want to expose the concept of virtualization to their users. For them virtualization is intended to be just a hidden impl detail of their application. Some issues which arise when using embedded virtualization - Need to invent sensible unique names for each VM launched. This leads to pollution of logfiles for QEMU instances run. - User sees libguestfs / virt-sandbox VMs in virt-manager / oVirt which they may then try to manage, breaking libguestfs / etc I didn't realize this before, but yes this is bad. - Disassociated process context, so if 'virt-sandbox' is placed in a cgroup, the VMs it launches are in a different cgroup. Likewise if custom env variables are set, work is needed to propagate those to VMs. This leads me to wonder whether it is worth exploring the idea of a new type of libvirt connection. - embed mode - no libvirtd, driver runs in application context Seems like an excellent idea. The idea here is to take libvirtd out of the equation and directly use the QEMU driver code in the libvirt.so client / application. Since libvirtd (mostly) uses the same APIs as the public libvirt.so clients, there isn't much required to make this work. - A way for the application to invoke virStateInit for the driver - Application must provide an event loop impl - A way to specify alternative dirs for logs/state/config/etc An application would access this mode using a different path for the driver, and specifying the path to use for logs/state/config etc. eg libguestfs might use qemu:///embed?statedir=/tmp/libguestfsX/ to get an instance of the QEMU driver that is completely private to itself. One question is whether there should be a single embed instance per process, or whether an application should be allowed to open multiple completely isolated embed instances. The latter might require is to eliminate more static variables in our code. This kind of embedded mode is not without its downsides though - How to access virtual network / storage / node device APIs ? libguestfs only uses (optionally) user networking. We also don't access any storage or node APIs, and don't intend to AFAIK. - Extra SELinux policy work to allow each app to have the same kind of privileges that libvirtd has to let it start VMs Right, this is important, and probably tricky. How about still running libvirtd, but per connection/process? (I think you mentioned before that this is in fact already possible). It costs 1 extra fork, but in the libguestfs scheme of things this won't make much difference. - How to troubleshoot - can't use things like 'virsh qemu-monitor-command' since the embedded instance is private to the application in question. For libguestfs this last one isn't important. One answer to the latter question, might be to actually allow the application to expose the same RPC service as libvirtd does. So virsh could connect to libguestfs using qemu:///embed?socketdir=/tmp/libguestfsX/libvirt-sock For the question of network/storage/node device access, the long term answer is probably to split up the system libvirtd instance into separate pieces. eg a virtnodedeviced, virtnetworkd, virstoraged, virtqemud, virtlxcd, etc. Now a client app would connect to their embedded QEMU instances, but to the shared nodedevice/network/storage daemons. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual
Re: [libvirt] [PATCH 0/3] add pci-bridge device and address type
在 2013-01-02三的 10:22 +,Daniel P. Berrange写道: On Wed, Dec 26, 2012 at 09:00:06AM +0800, liguang wrote: Now, it's unnecessary to arrange devices into multi-pci-bus, for example: sound model='ac97' address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x0'/ /sound video model type='cirrus' vram='9216' heads='1'/ address type='pci' domain='0x' bus='0x1' slot='0x02' function='0x0'/ /video libvirt will complain about bus != 0, fortunately, qemu supports pci-to-pci bridge, if we want to use multi-pci-bus, we can define 2 pci bridge devices then attach 1 to the other as a subordinate pci-bus, so, 2 pci-buses appear. for example: pci-bridge type='root'/ pci-bridge type='subordinate' address type='pci-bridge' domain='0x' bus='0x00' slot='0x04' function='0x0'/ /pci-bridge We shouldn't be introducing a new pci-bridge device for this. The existing controller element is intended to handle all types of bus devices. Just need to define a new controller type. okay, let me try to do it. Daniel -- regards! li guang -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] Refactoring bridge driver for portability
Laine Stump wrote: On 12/23/2012 07:54 AM, Roman Bogorodskiy wrote: Hi, Few weeks ago when I have submitted my all-in-one huge FreeBSD, Eric made some comments on the networking part: http://www.redhat.com/archives/libvir-list/2012-December/msg00432.html Now when we're done with most of the other things, I'd like to discuss networking in more detail. Basically, the main question that bothers me is what would be the best way to refactor network/bridge_driver.c? Currently it contains a number of things: - dnsmasq routines, static, but cross-platform, doesn't need any changes (at least major ones) - the same for radvd - minor firewalld bits, that are linux specifc - iptables routines. There are quite a lot of that code and it's also gets called from many places in the file Note that there is already viriptables.c in src/util. Of course those are lower level primitives, but they were really created with the needs of bridge_driver.c in mind. I'm thinking about an approach that Eric mentioned for virthread.c: - keep dnsmasq and radvd in bridge_driver.c - move out all linux specific code to bridge_driver_linux.c and #include it in a way similar to virthread.c I must have missed that message. I dislike #including .c files, if that's what you're talking about. - in a similar way create bridge_driver_freebsd.c Does it sound reasonable? I don't mind the idea of bridge_driver_xxx.c and bridge_driver.c, but I think that the appropriate bridge_driver_xxx.c should be added to the Makefile rather than #included in bridge_driver.c. I would do it by having a common .h file bridge_driver_platform.h which had a set of functions that must be defined for any supported platform, then rewrite bridge_driver.c so that everything that isn't platform-independent is turned into a call to a function or functions declared in bridge_driver_platform.h and defined in bridge_driver_(linux|freebsd).c For example, the firewalld/dbus specific stuff can be considered as an opaque chunk of Linux specific code that must be executed during networkStartup(). I think that can be taken care of by declaring a function networkStartupPlatform() in bridge_driver_platform.h, then defining it in both bridge_driver_linux.c and bridge_driver_freebsd.c (where it may simply return success.) All of the seemingly iptables-specific functions bridge_driver.c should be renamed to use a more generic term in place of iptables: networkAddIpSpecificIptablesRules networkAddMasqueradingFilterRules networkAddRoutingFilterRules networkReloadFilterRules networkRemoveFilterRules networkRemoveIpSPecificFilterRules networkRemoveGeneralFilterRules [etc] Almost all of those functions should be able to remain in bridge_driver.c; only the bottom-level functions that are directly calling iptables(Add|Remove)*() functions should need to be moved to bridge_driver_xxx.c (and re-written appropriately for FreeBSD). (Or maybe the concepts behind the functions declared in src/util/viriptables.h are generic enough that those functions should also be renamed, and a new src/util/virpf.c (or whatever filtering package is used on FreeeBSD these days - I haven't kept up with BSD for a long time) defined that implements these filter*() functions for that platform. That sounds reasonable, I'll start moving this way. Thanks Roman Bogorodskiy pgphK7nlAuitW.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/2]add usb-serial virtual device support for qemu
This two patches are trying to add support for qemu virtual device usb-serial. Add an optional 'type' attribute to target element of serial port device. There are two choices for its value, 'isa-serial' and 'usb-serial'. For backward compatibility, when attribute 'type' is missing the 'isa-serial' will be chose as before. Libvirt XML sample serial type='pty' target type='usb-serial' port='0'/ address type='usb' bus='0' port='1'/ /serial qemu commandline: qemu ${other_vm_args} \ -chardev pty,id=charserial0\ -device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1 Guannan Ren(2) [PATCH 1/2] qemu: add usb-serial caps flag [PATCH 2/2] qemu: add usb-serial support docs/formatdomain.html.in | 9 - docs/schemas/domaincommon.rng | 20 +--- src/conf/domain_conf.c| 42 +++--- src/conf/domain_conf.h| 10 ++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 24 ++-- tests/qemuhelptest.c | 21 ++--- 9 files changed, 115 insertions(+), 16 deletions(-) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] qemu: add usb-serial support
Add an optional 'type' attribute to target element of serial port device. There are two choices for its value, 'isa-serial' and 'usb-serial'. For backward compatibility, when attribute 'type' is missing the 'isa-serial' will be chose as before. Libvirt XML sample serial type='pty' target type='usb-serial' port='0'/ address type='usb' bus='0' port='1'/ /serial qemu commandline: qemu ${other_vm_args} \ -chardev pty,id=charserial0\ -device usb-serial,chardev=charserial0,id=serial0,bus=usb.0,port=1 --- docs/formatdomain.html.in | 9 - docs/schemas/domaincommon.rng | 20 +--- src/conf/domain_conf.c| 42 +++--- src/conf/domain_conf.h| 10 ++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_command.c | 24 ++-- 6 files changed, 98 insertions(+), 9 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 94df6f8..7241bb9 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3677,7 +3677,14 @@ qemu-kvm -net nic,model=? /dev/null p codetarget/code can have a codeport/code attribute, which specifies the port number. Ports are numbered starting from 0. There are - usually 0, 1 or 2 serial ports. + usually 0, 1 or 2 serial ports. There is also an optional + codetype/code attribute span class=sinceSince 1.0.2/span + which has two choices for its value, one is codeisa-serial/code, + the other is codeusb-serial/code. If codetype/code is missing, + codeisa-serial/code will be used by default. For codeusb-serial/code + an optional sub-element codelt;addressgt;/code with + codetype='usb'/codewhich can tie the device to a particular controller, + a href=#elementsAddressdocumentedabove/a. /p h6a name=elementCharConsoleConsole/a/h6 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 0529d62..7b7a2f9 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2453,12 +2453,26 @@ /attribute /define + define name='qemucdevSerialTgtType' +attribute name='type' + choice +valueisa-serial/value +valueusb-serial/value + /choice +/attribute + /define + define name=qemucdevTgtDef element name=target interleave -optional - ref name=qemucdevConsoleTgtType/ -/optional +choice + optional +ref name=qemucdevConsoleTgtType/ + /optional + optional +ref name=qemucdevSerialTgtType/ + /optional +/choice optional attribute name=port/ /optional diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 79af087..9ece160 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -336,6 +336,11 @@ VIR_ENUM_IMPL(virDomainNetInterfaceLinkState, VIR_DOMAIN_NET_INTERFACE_LINK_STAT up, down) +VIR_ENUM_IMPL(virDomainChrSerialTarget, + VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST, + isa-serial, + usb-serial) + VIR_ENUM_IMPL(virDomainChrChannelTarget, VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST, none, @@ -5445,6 +5450,9 @@ virDomainChrDefaultTargetType(virCapsPtr caps, break; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: +target = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; +break; + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: default: /* No target type yet*/ @@ -5457,7 +5465,8 @@ virDomainChrDefaultTargetType(virCapsPtr caps, static int virDomainChrTargetTypeFromString(virCapsPtr caps, - virDomainDefPtr def, + virDomainDefPtr vmdef, + virDomainChrDefPtr def, int devtype, const char *targetType) { @@ -5465,7 +5474,7 @@ virDomainChrTargetTypeFromString(virCapsPtr caps, int target = 0; if (!targetType) { -target = virDomainChrDefaultTargetType(caps, def, devtype); +target = virDomainChrDefaultTargetType(caps, vmdef, devtype); goto out; } @@ -5479,12 +5488,17 @@ virDomainChrTargetTypeFromString(virCapsPtr caps, break; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: +target = virDomainChrSerialTargetTypeFromString(targetType); +break; + case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: default: /* No target type yet*/ break; } +def-targetType_attr = true; + out: ret = target; return ret; @@ -5503,7 +5517,7 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, const char *portStr = NULL; if ((def-targetType = - virDomainChrTargetTypeFromString(caps, vmdef, +
[libvirt] [PATCH 1/2] qemu: add usb-serial caps flag
QEMU_CAPS_DEVICE_USB_SERIAL /* -device usb-serial */ --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemuhelptest.c | 21 ++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 17e6679..1fe9d07 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -199,6 +199,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, cirrus-vga, vmware-svga, device-video-primary, + usb-serial, ); struct _qemuCaps { @@ -1343,6 +1344,7 @@ struct qemuCapsStringFlags qemuCapsObjectTypes[] = { { VGA, QEMU_CAPS_DEVICE_VGA }, { cirrus-vga, QEMU_CAPS_DEVICE_CIRRUS_VGA }, { vmware-svga, QEMU_CAPS_DEVICE_VMWARE_SVGA }, +{ usb-serial, QEMU_CAPS_DEVICE_USB_SERIAL}, }; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3457852..d939821 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -162,6 +162,7 @@ enum qemuCapsFlags { QEMU_CAPS_DEVICE_VMWARE_SVGA = 122, /* -device vmware-svga */ QEMU_CAPS_DEVICE_VIDEO_PRIMARY = 123, /* safe to use -device XXX for primary video device */ +QEMU_CAPS_DEVICE_USB_SERIAL = 124, /* -device usb-serial */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 252ad3a..b71c292 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -395,7 +395,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_SERIAL); DO_TEST(qemu-kvm-0.12.3, 12003, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -502,7 +503,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_SERIAL); DO_TEST(qemu-kvm-0.12.1.2-rhel61, 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -565,7 +567,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_SERIAL); DO_TEST(qemu-kvm-0.12.1.2-rhel62-beta, 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -715,7 +718,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_SERIAL); DO_TEST(qemu-1.1.0, 1001000, 0, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -801,7 +805,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_SERIAL); DO_TEST(qemu-1.2.0, 1002000, 0, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -898,7 +903,8 @@ mymain(void) QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, -QEMU_CAPS_DEVICE_VIDEO_PRIMARY); +QEMU_CAPS_DEVICE_VIDEO_PRIMARY, +QEMU_CAPS_DEVICE_USB_SERIAL); DO_TEST(qemu-kvm-1.2.0, 1002000, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -1000,7 +1006,8 @@ mymain(void) QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, -QEMU_CAPS_DEVICE_VIDEO_PRIMARY); +QEMU_CAPS_DEVICE_VIDEO_PRIMARY, +QEMU_CAPS_DEVICE_USB_SERIAL); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 1.7.11.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/3] network: fix typos and docs
--- docs/formatdomain.html.in | 9 ++--- src/conf/domain_conf.c| 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 94df6f8..45d7593 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2546,12 +2546,15 @@ virtualport types (and also to leave out certain attributes); at domain startup time, a complete codelt;virtualportgt;/code element will be constructed by merging together the type and - attributes found in the which will be filled in from the network - or portgroup codelt;virtualportgt;/code) + attributes defined in the network and the portgroup referenced + by the interface. The newly-constructed virtualport is a combination + of them. The attributes from lower virtualport can't make change + to the ones defined in higher virtualport. + Interface takes the highest priority, portgroup is lowest priority. (span class=sinceSince 0.10.0/span). For example, in order to work properly with both an 802.1Qbh switch and an Open vSwitch switch, you may choose to specify no type, but both - an codeinstanceid/code (in case the switch is 802.1Qbh) and + an codeprofileid/code (in case the switch is 802.1Qbh) and an codeinterfaceid/code (in case the switch is Open vSwitch) (you may also omit the other attributes, such as managerid, typeid, or profileid, to be filled in from the diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 79af087..70c1ee7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4994,7 +4994,7 @@ virDomainNetDefParseXML(virCapsPtr caps, def-type == VIR_DOMAIN_NET_TYPE_INTERNAL xmlStrEqual(cur-name, BAD_CAST source)) { internal = virXMLPropString(cur, name); -} else if (!network +} else if (!bridge def-type == VIR_DOMAIN_NET_TYPE_BRIDGE xmlStrEqual(cur-name, BAD_CAST source)) { bridge = virXMLPropString(cur, bridge); @@ -5028,7 +5028,7 @@ virDomainNetDefParseXML(virCapsPtr caps, interface type='%s'), type); goto error; } -} else if (!network +} else if (!address (def-type == VIR_DOMAIN_NET_TYPE_SERVER || def-type == VIR_DOMAIN_NET_TYPE_CLIENT || def-type == VIR_DOMAIN_NET_TYPE_MCAST) -- 1.7.11.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/3]add usb-net support for qemu
The set of patches fixed some typo in network docs and codes and is trying to support usb-net qemu virtual device. The following is an example for use. Libvirt XML sample: devices interface type='user' mac address='52:54:00:32:6a:91'/ model type='usb-net'/ alias name='net1'/ address type='usb' bus='0' port='1'/ /interface /devices qemu commandline: qemu ${other_vm_args} -netdev user,id=hostnet1 \ -device usb-net,netdev=hostnet1,id=net1,\ mac=52:54:00:32:6a:91,bus=usb.0,port=1 Guannan Ren(3) [PATCH 1/3] network: fix typos and docs [PATCH 2/3] qemu: add usb-net caps flag [PATCH 3/3] qemu: add usb-net support docs/formatdomain.html.in| 13 + src/conf/domain_conf.c | 22 +++--- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 8 +++- tests/qemuhelptest.c | 21 ++--- 6 files changed, 48 insertions(+), 19 deletions(-) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] qemu: add usb-net caps flag
QEMU_CAPS_DEVICE_USB_NET /* -device usb-net */ --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemuhelptest.c | 21 ++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 17e6679..1e1365c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -199,6 +199,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, cirrus-vga, vmware-svga, device-video-primary, + usb-net, ); struct _qemuCaps { @@ -1343,6 +1344,7 @@ struct qemuCapsStringFlags qemuCapsObjectTypes[] = { { VGA, QEMU_CAPS_DEVICE_VGA }, { cirrus-vga, QEMU_CAPS_DEVICE_CIRRUS_VGA }, { vmware-svga, QEMU_CAPS_DEVICE_VMWARE_SVGA }, +{ usb-net, QEMU_CAPS_DEVICE_USB_NET}, }; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3457852..f6d4f1d 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -162,6 +162,7 @@ enum qemuCapsFlags { QEMU_CAPS_DEVICE_VMWARE_SVGA = 122, /* -device vmware-svga */ QEMU_CAPS_DEVICE_VIDEO_PRIMARY = 123, /* safe to use -device XXX for primary video device */ +QEMU_CAPS_DEVICE_USB_NET = 124, /* -device usb-net */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 252ad3a..6941c90 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -395,7 +395,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-kvm-0.12.3, 12003, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -502,7 +503,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-kvm-0.12.1.2-rhel61, 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -565,7 +567,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-kvm-0.12.1.2-rhel62-beta, 12001, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -715,7 +718,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-1.1.0, 1001000, 0, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -801,7 +805,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-1.2.0, 1002000, 0, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -898,7 +903,8 @@ mymain(void) QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, -QEMU_CAPS_DEVICE_VIDEO_PRIMARY); +QEMU_CAPS_DEVICE_VIDEO_PRIMARY, +QEMU_CAPS_DEVICE_USB_NET); DO_TEST(qemu-kvm-1.2.0, 1002000, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -1000,7 +1006,8 @@ mymain(void) QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, -QEMU_CAPS_DEVICE_VIDEO_PRIMARY); +QEMU_CAPS_DEVICE_VIDEO_PRIMARY, +QEMU_CAPS_DEVICE_USB_NET); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 1.7.11.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/3] qemu: add usb-net support
Libvirt XML sample: devices interface type='user' mac address='52:54:00:32:6a:91'/ model type='usb-net'/ alias name='net1'/ address type='usb' bus='0' port='1'/ /interface /devices qemu commandline: qemu ${other_vm_args} -netdev user,id=hostnet1 \ -device usb-net,netdev=hostnet1,id=net1,\ mac=52:54:00:32:6a:91,bus=usb.0,port=1 --- docs/formatdomain.html.in | 4 +++- src/conf/domain_conf.c| 18 +- src/qemu/qemu_command.c | 8 +++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 45d7593..fbd77f2 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2952,7 +2952,9 @@ qemu-kvm -net nic,model=? /dev/null p Typical values for QEMU and KVM include: - ne2k_isa i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio + ne2k_isa i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio. + Besides above, there is a model of usb-net which is a QEMU USB Network interface + span class=sinceSince 1.0.2 (QEMU and KVM only)/span /p h5a name=elementsDriverBackendOptionsSetting NIC driver-specific options/a/h5 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 70c1ee7..94cd059 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5131,14 +5131,15 @@ virDomainNetDefParseXML(virCapsPtr caps, goto error; } -/* XXX what about ISA/USB based NIC models - once we support +/* XXX what about ISA based NIC models - once we support * them we should make sure address type is correct */ if (def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 -def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { +def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI +def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { virReportError(VIR_ERR_INTERNAL_ERROR, %s, - _(Network interfaces must use 'pci' address type)); + _(Network interfaces have incorrect address type)); goto error; } @@ -5301,9 +5302,16 @@ virDomainNetDefParseXML(virCapsPtr caps, virReportError(VIR_ERR_INVALID_ARG, %s, _(Model name contains invalid characters)); goto error; +} else if (STREQ(model, usb-net) + def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE + def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(Interface of usb-net model requires address of usb type)); +goto error; +} else { +def-model = model; +model = NULL; } -def-model = model; -model = NULL; } if (def-model STREQ(def-model, virtio)) { diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8a3de09..b3ce76a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1558,7 +1558,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, * instead of here. */ if ((def-nets[i]-type == VIR_DOMAIN_NET_TYPE_HOSTDEV) || -(def-nets[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) { +(def-nets[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) || +(STREQ_NULLABLE(def-nets[i]-model, usb-net))) { continue; } if (qemuDomainPCIAddressSetNextAddr(addrs, def-nets[i]-info) 0) @@ -3180,6 +3181,11 @@ qemuBuildNicDevStr(virDomainNetDefPtr net, nic = virtio-net-pci; } usingVirtio = true; +} else if (STREQ(net-model, usb-net) + !qemuCapsGet(caps, QEMU_CAPS_DEVICE_USB_NET)) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(usb-net is not supported in this QEMU binary)); +goto error; } else { nic = net-model; } -- 1.7.11.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/3] qemu: add usb-audio caps flag
QEMU_CAPS_DEVICE_USB_AUDIO /* -device usb-audio */ --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemuhelptest.c | 9 ++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 17e6679..3b6ce50 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -199,6 +199,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, cirrus-vga, vmware-svga, device-video-primary, + usb-audio, ); struct _qemuCaps { @@ -1343,6 +1344,7 @@ struct qemuCapsStringFlags qemuCapsObjectTypes[] = { { VGA, QEMU_CAPS_DEVICE_VGA }, { cirrus-vga, QEMU_CAPS_DEVICE_CIRRUS_VGA }, { vmware-svga, QEMU_CAPS_DEVICE_VMWARE_SVGA }, +{ usb-audio, QEMU_CAPS_DEVICE_USB_AUDIO}, }; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3457852..ed56b9a 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -162,6 +162,7 @@ enum qemuCapsFlags { QEMU_CAPS_DEVICE_VMWARE_SVGA = 122, /* -device vmware-svga */ QEMU_CAPS_DEVICE_VIDEO_PRIMARY = 123, /* safe to use -device XXX for primary video device */ +QEMU_CAPS_DEVICE_USB_AUDIO = 124, /* -device usb-audio */ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 252ad3a..7576258 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -801,7 +801,8 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, -QEMU_CAPS_DEVICE_VMWARE_SVGA); +QEMU_CAPS_DEVICE_VMWARE_SVGA, +QEMU_CAPS_DEVICE_USB_AUDIO); DO_TEST(qemu-1.2.0, 1002000, 0, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -898,7 +899,8 @@ mymain(void) QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, -QEMU_CAPS_DEVICE_VIDEO_PRIMARY); +QEMU_CAPS_DEVICE_VIDEO_PRIMARY, +QEMU_CAPS_DEVICE_USB_AUDIO); DO_TEST(qemu-kvm-1.2.0, 1002000, 1, 0, QEMU_CAPS_VNC_COLON, QEMU_CAPS_NO_REBOOT, @@ -1000,7 +1002,8 @@ mymain(void) QEMU_CAPS_DEVICE_VGA, QEMU_CAPS_DEVICE_CIRRUS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA, -QEMU_CAPS_DEVICE_VIDEO_PRIMARY); +QEMU_CAPS_DEVICE_VIDEO_PRIMARY, +QEMU_CAPS_DEVICE_USB_AUDIO); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 1.7.11.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/3] test: add usb-audio testcase
--- tests/qemuxml2argvdata/qemuxml2argv-usb-audio.args | 7 + tests/qemuxml2argvdata/qemuxml2argv-usb-audio.xml | 31 ++ tests/qemuxml2argvtest.c | 3 +++ 3 files changed, 41 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-audio.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-audio.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-audio.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-audio.args new file mode 100644 index 000..fe2551f --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-audio.args @@ -0,0 +1,7 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu \ +-S -M pc-0.15 -m 1024 -smp 1 -nographic -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-hda /var/lib/libvirt/images/QEMUGuest1 \ +-device usb-audio,id=sound0,buffer=1536,bus=usb.0,port=1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-audio.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-audio.xml new file mode 100644 index 000..037d71a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-audio.xml @@ -0,0 +1,31 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidcdbebdfa-1d6d-65c3-be0f-fd74b978a773/uuid + memory unit='KiB'1048576/memory + currentMemory unit='KiB'1048576/currentMemory + vcpu placement='static'1/vcpu + os +type arch='x86_64' machine='pc-0.15'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashrestart/on_crash + devices +emulator/usr/bin/qemu/emulator +disk type='file' device='disk' + driver name='qemu' type='qcow2' cache='none'/ + source file='/var/lib/libvirt/images/QEMUGuest1'/ + target dev='hda' bus='ide'/ + address type='drive' controller='0' bus='0' target='0' unit='0'/ +/disk +controller type='usb' index='0' model='piix3-uhci'/ +controller type='ide' index='0' +/controller +sound model='usb-audio' + buffer1536/buffer + address type='usb' bus='0' port='1'/ +/sound + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 9e2c4e4..7405583 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -767,6 +767,9 @@ mymain(void) DO_TEST(sound-device, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_HDA_MICRO); +DO_TEST(usb-audio, +QEMU_CAPS_DEVICE, QEMU_CAPS_PIIX3_USB_UHCI, +QEMU_CAPS_DEVICE_USB_AUDIO, QEMU_CAPS_PCI_MULTIFUNCTION); DO_TEST(fs9p, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_FSDEV, QEMU_CAPS_FSDEV_WRITEOUT); -- 1.7.11.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] qemu: parse usb-audio audio device XML and docs
usb-audio XML example: devices sound model='usb-audio' buffer1536/buffer address type='usb' bus='0' port='1'/ /sound /devices qemu ${other_vm_args} \ -device usb-audio,id=sound0,buffer=1536,bus=usb.0,port=1 there is an optional sub-element buffer to customize the buffer size of usb audio device, if missing, the default size is 1536(defined in qemu code). Special size of value 0 means no buffer will be used, so we use bool 'customized_buffer'to differentiate user-defined 0 from being using default buffer value 1536. --- docs/formatdomain.html.in | 10 +++-- docs/schemas/basictypes.rng | 11 ++ docs/schemas/domaincommon.rng | 9 docs/schemas/nwfilter.rng | 15 - src/conf/domain_conf.c| 49 ++- src/conf/domain_conf.h| 5 + src/qemu/qemu_command.c | 19 - 7 files changed, 99 insertions(+), 19 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 94df6f8..354d4f6 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4056,9 +4056,15 @@ qemu-kvm -net nic,model=? /dev/null The codesound/code element has one mandatory attribute, codemodel/code, which specifies what real sound device is emulated. Valid values are specific to the underlying hypervisor, though typical -choices are 'es1370', 'sb16', 'ac97', and 'ich6' +choices are 'es1370', 'sb16', 'ac97', 'ich6' and 'usb-audio' (span class=since - 'ac97' only since 0.6.0, 'ich6' only since 0.8.8/span) + 'ac97' only since 0.6.0, 'ich6' only since 0.8.8, + 'usb-audio' only since 1.0.2/span) +For the 'usb-audio' model, there is an optional sub-element codelt;buffergt;/code +to customize the buffer size of the audio device, if missing, the default size is 1536. +The goal of setting a buffer size is to reduce it as much as possible without +hearing any clicks, pops, or other glitches. Special size of value 0 means no buffer +will be used, e.g. codelt;buffergt;3072lt;/buffergt;/code. /dd /dl diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index 38cab16..4e8d4b8 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -42,6 +42,17 @@ /data /choice /define + define name=uint32range +choice + data type=string +param name=pattern0x[0-9a-fA-F]{1,8}/param + /data + data type=long +param name=minInclusive0/param +param name=maxInclusive4294967295/param + /data +/choice + /define define name=UUID choice diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 0529d62..55c1219 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2599,6 +2599,11 @@ /attribute /element /define + define name=audiobuffer +element name='buffer' + ref name=uint32range/ +/element + /define define name=sound element name=sound attribute name=model @@ -2608,6 +2613,7 @@ valuepcspk/value valueac97/value valueich6/value + valueusb-audio/value /choice /attribute interleave @@ -2622,6 +2628,9 @@ ref name=codec/ /choice /zeroOrMore +optional + ref name =audiobuffer/ +/optional /interleave /element /define diff --git a/docs/schemas/nwfilter.rng b/docs/schemas/nwfilter.rng index cfd9ba5..5681083 100644 --- a/docs/schemas/nwfilter.rng +++ b/docs/schemas/nwfilter.rng @@ -942,21 +942,6 @@ /choice /define - define name=uint32range -choice - ref name=variable-name-type/ - - data type=string -param name=pattern0x[0-9a-fA-F]{1,8}/param - /data - - data type=int -param name=minInclusive0/param -param name=maxInclusive4294967295/param - /data -/choice - /define - define name=boolean choice valueyes/value diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 79af087..955e089 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -395,7 +395,8 @@ VIR_ENUM_IMPL(virDomainSoundModel, VIR_DOMAIN_SOUND_MODEL_LAST, es1370, pcspk, ac97, - ich6) + ich6, + usb-audio) VIR_ENUM_IMPL(virDomainMemDump, VIR_DOMAIN_MEM_DUMP_LAST, default, @@ -7009,6 +7010,38 @@ error: goto cleanup; } +static int +virDomainSoundUSBAudioBufferParseXML(const xmlNodePtr node, + xmlXPathContextPtr ctxt, + virDomainSoundDefPtr def) +{ +int ret; +unsigned long value; + +if (!node || !ctxt) +return -1; + +ret = virXPathULong(string(./buffer[1]), ctxt, value); +if
[libvirt] [PATCH 0/3]add usb-audio support
This set of patches is trying to add qemu usb-audio virtual device support. usb-audio XML example: devices sound model='usb-audio' buffer1536/buffer address type='usb' bus='0' port='1'/ /sound /devices qemu ${other_vm_args} \ -device usb-audio,id=sound0,buffer=1536,bus=usb.0,port=1 There is an optional sub-element buffer to customize the buffer size of usb audio device, if missing, the default size is 1536(defined in qemu code). Special size of value 0 means no buffer will be used, so we use bool 'customized_buffer'to differentiate user-defined 0 from being using default buffer value 1536. Guannan Ren(3) [PATCH 1/3] qemu: add usb-audio caps flag [PATCH 2/3] qemu: parse usb-audio audio device XML and docs [PATCH 3/3] test: add usb-audio testcase docs/formatdomain.html.in | 10 -- docs/schemas/basictypes.rng| 11 +++ docs/schemas/domaincommon.rng | 9 + docs/schemas/nwfilter.rng | 15 --- src/conf/domain_conf.c | 49 - src/conf/domain_conf.h | 5 + src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c| 19 ++- tests/qemuhelptest.c | 9 ++--- tests/qemuxml2argvdata/qemuxml2argv-usb-audio.args | 7 +++ tests/qemuxml2argvdata/qemuxml2argv-usb-audio.xml | 31 +++ tests/qemuxml2argvtest.c | 3 +++ 13 files changed, 149 insertions(+), 22 deletions(-) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list