Re: [libvirt] [libvirt-sandbox PATCH 1/2] main: Don't free error twice
On Sun, Feb 26, 2012 at 07:11:29PM +, Daniel P. Berrange wrote: On Sun, Feb 26, 2012 at 01:49:33PM +0100, Guido Günther wrote: It's already being cleared in cleanup. Otherwise we see: Unknown option -D Run 'libvirt-sandbox --help' to see a full list of available command line options *** glibc detected *** /var/scratch/debian/libvirt-sandbox/libvirt-sandbox/bin/.libs/lt-virt-sandbox: double free or corruption (fasttop): 0x08d888b0 *** === Backtrace: = /lib/i386-linux-gnu/i686/cmov/libc.so.6(+0x6e221)[0xb7255221] /lib/i386-linux-gnu/i686/cmov/libc.so.6(+0x6fa88)[0xb7256a88] /lib/i386-linux-gnu/i686/cmov/libc.so.6(cfree+0x6d)[0xb7259b3d] /lib/i386-linux-gnu/libglib-2.0.so.0(+0x4c38b)[0xb73c038b] /lib/i386-linux-gnu/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0xb71fde46] --- bin/virt-sandbox.c |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/bin/virt-sandbox.c b/bin/virt-sandbox.c index b24b24b..00b2a29 100644 --- a/bin/virt-sandbox.c +++ b/bin/virt-sandbox.c @@ -112,7 +112,6 @@ int main(int argc, char **argv) { g_printerr(%s\n%s\n, error-message, gettext(help_msg)); -g_error_free(error); goto cleanup; } ACK, don't forget to add yourself to AUTHORS when pushing, so that 'make syntax-check' still passes Done and both pushed. Thanks, -- Guido -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/2] Implement sysinfo for PowerPC, improve its behaviour on x86.
On 02/16/2012 05:03 PM, Prerna wrote: This series of patches implements the following: Patch 1/2 : Implement sysinfo for PowerPC. OnPowerPC, sysinfo is obtained by reading /proc/cpuinfo since dmidecode is not available. Patch 2/2 : Based on Eric's suggestion (http://www.redhat.com/archives/libvir-list/2012-February/msg00509.html), Allow x86 to read host system's processor information from /proc/cpuinfo in the event dmidecode is not available. Changelog: * Patch 1: Rebased and cleanups done. * Patch 2: New. Hi, Any thoughts on this patch series ? I will be happy to modify the output information based on feedback. Thanks, -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] libxl: eliminate memory leak in libxmlDomainModifyDeviceFlags
I found this randomly by examination when a tag search led me to this file. I don't have a setup to test it, but it appears fairly obvious that this call to virDomainDeviceDefParse is both unnecessary (since it will again be called at the top of the immediately following if(), and if not there, then at the top of the if following that), but it also creates a leak of one virDomainDeviceDef and one [whatever type of device the DeviceDef is pointing to; probably a virDomainDiskDef] in the case that the function has been called with VIR_DOMAIN_DEVICE_MODIFY_CONFIG (the second parse will overwrite the devicedef that was just created). --- src/libxl/libxl_driver.c |4 1 files changed, 0 insertions(+), 4 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 6db33c2..d5fa64a 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3243,10 +3243,6 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto cleanup; } -if (!(dev = virDomainDeviceDefParse(driver-caps, vm-def, xml, - VIR_DOMAIN_XML_INACTIVE))) -goto cleanup; - priv = vm-privateData; if (flags VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 7/7] tests: Add tests for virtio-scsi and ibmvscsi controllers
--- .../qemuxml2argv-disk-scsi-virtio-scsi.args|9 + .../qemuxml2argv-disk-scsi-virtio-scsi.xml | 32 .../qemuxml2argv-disk-scsi-vscsi.args |8 + .../qemuxml2argv-disk-scsi-vscsi.xml | 32 tests/qemuxml2argvtest.c |4 ++ tests/qemuxml2xmltest.c|4 ++- 6 files changed, 88 insertions(+), 1 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.args new file mode 100644 index 000..de8d5a6 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.args @@ -0,0 +1,9 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device \ +virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -drive file=/dev/HostVG/QEMUGuest1,\ +if=none,id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,\ +drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/tmp/scsidisk.img,if=none,\ +id=drive-scsi0-0-0-0 -device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\ +drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 -usb -device virtio-balloon-pci,\ +id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.xml new file mode 100644 index 000..7395baa --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.xml @@ -0,0 +1,32 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory219136/memory + currentMemory219136/currentMemory + vcpu1/vcpu + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashdestroy/on_crash + devices +emulator/usr/bin/qemu/emulator +disk type='block' device='disk' + source dev='/dev/HostVG/QEMUGuest1'/ + target dev='hda' bus='ide'/ + address type='drive' controller='0' bus='0' target='0' unit='0'/ +/disk +disk type='file' device='disk' + source file='/tmp/scsidisk.img'/ + target dev='sda' bus='scsi'/ + address type='drive' controller='0' bus='0' target='0' unit='0'/ +/disk +controller type='ide' index='0'/ +controller type='scsi' index='0' model='virtio-scsi'/ +controller type='usb' index='0'/ +memballoon model='virtio'/ + /devices +/domain diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.args new file mode 100644 index 000..8f2dd35 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.args @@ -0,0 +1,8 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device spapr-vscsi,id=scsi0,\ +bus=pci.0,addr=0x3 -drive file=/dev/HostVG/QEMUGuest1,if=none,\ +id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +-drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0-0 \ +-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \ +-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.xml new file mode 100644 index 000..ea72ca0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.xml @@ -0,0 +1,32 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory219136/memory + currentMemory219136/currentMemory + vcpu1/vcpu + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashdestroy/on_crash + devices +emulator/usr/bin/qemu/emulator +disk type='block' device='disk' + source dev='/dev/HostVG/QEMUGuest1'/ + target dev='hda' bus='ide'/ + address type='drive' controller='0' bus='0' target='0' unit='0'/ +/disk +disk type='file' device='disk' + source file='/tmp/scsidisk.img'/ + target dev='sda' bus='scsi'/ + address type='drive' controller='0' bus='0' target='0' unit='0'/ +/disk +controller type='ide' index='0'/ +controller type='scsi' index='0'
[libvirt] [PATCH 3/7] conf: Add helper function to look up disk controller model
--- src/conf/domain_conf.c | 17 + src/conf/domain_conf.h |3 +++ src/libvirt_private.syms |1 + 3 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 93501cf..2b68841 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2503,6 +2503,23 @@ virDomainParseLegacyDeviceAddress(char *devaddr, } int +virDomainDiskFindControllerModel(virDomainDefPtr def, + virDomainDiskDefPtr disk, + int controllerType) +{ +int model = -1; +int i; + +for (i = 0; i def-ncontrollers; i++) { +if (def-controllers[i]-type == controllerType +def-controllers[i]-idx == disk-info.addr.drive.controller) +model = def-controllers[i]-model; +} + +return model; +} + +int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def) { int idx = virDiskNameToIndex(def-dst); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 777bccb..fed7cc3 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1729,6 +1729,9 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def); void virDomainInputDefFree(virDomainInputDefPtr def); void virDomainDiskDefFree(virDomainDiskDefPtr def); void virDomainDiskHostDefFree(virDomainDiskHostDefPtr def); +int virDomainDiskFindControllerModel(virDomainDefPtr def, + virDomainDiskDefPtr disk, + int controllerType); void virDomainControllerDefFree(virDomainControllerDefPtr def); void virDomainFSDefFree(virDomainFSDefPtr def); void virDomainActualNetDefFree(virDomainActualNetDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 310cd7d..1ecb533 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -302,6 +302,7 @@ virDomainDiskDefFree; virDomainDiskDeviceTypeToString; virDomainDiskErrorPolicyTypeFromString; virDomainDiskErrorPolicyTypeToString; +virDomainDiskFindControllerModel; virDomainDiskIndexByName; virDomainDiskInsert; virDomainDiskInsertPreAlloced; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/7] qemu: add ibmvscsi controller model
From: Paolo Bonzini pbonzini@redhat com KVM will be able to use a PCI SCSI controller even on POWER. Let the user specify the vSCSI controller by other means than a default. After this patch, the QEMU driver will actually look at the model and reject anything but auto, lsilogic and ibmvscsi. Signed-off-by: Paolo Bonzini pbonzini@redhat com Signed-off-by: Osier Yangjyang@redhat com --- docs/formatdomain.html.in |4 ++-- docs/schemas/domaincommon.rng |1 + src/conf/domain_conf.c|3 ++- src/conf/domain_conf.h|1 + src/qemu/qemu_command.c | 29 + src/vmx/vmx.c |3 ++- 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 5305f82..25f8da5 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1657,8 +1657,8 @@ attributes codeports/code and codevectors/code, which control how many devices can be connected through the controller. A scsi controller has an optional - attribute codemodel/code, which is one of auto, - buslogic, lsilogic, lsias1068, or vmpvscsi. + attribute codemodel/code, which is one of auto, buslogic, + ibmvscsi, lsilogic, lsias1068, or vmpvscsi. A usb controller has an optional attribute codemodel/code, which is one of piix3-uhci, piix4-uhci, ehci, ich9-ehci1, ich9-uhci1, ich9-uhci2, ich9-uhci3, diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e276a92..d3deaea 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1120,6 +1120,7 @@ valuelsilogic/value valuelsisas1068/value valuevmpvscsi/value +valueibmvscsi/value valuepiix3-uhci/value valuepiix4-uhci/value valueehci/value diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b0c3fa6..18e8b97 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -238,7 +238,8 @@ VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAS buslogic, lsilogic, lsisas1068, - vmpvscsi) + vmpvscsi, + ibmvscsi); VIR_ENUM_IMPL(virDomainControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST, piix3-uhci, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9c8792a..aa8c824 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -452,6 +452,7 @@ enum virDomainControllerModelSCSI { VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI, +VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e783f22..90d9948 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -461,6 +461,15 @@ static int qemuAssignDeviceDiskAliasFixed(virDomainDiskDefPtr disk) return 0; } +static int +qemuDefaultScsiControllerModel(virDomainDefPtr def) { +if (STREQ(def-os.arch, ppc64) +STREQ(def-os.machine, pseries)) { +return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI; +} else { +return VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC; +} +} /* Our custom -drive naming scheme used with id= */ static int qemuAssignDeviceDiskAliasCustom(virDomainDiskDefPtr disk) @@ -2356,14 +2365,26 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef, int *nusbcontroller) { virBuffer buf = VIR_BUFFER_INITIALIZER; +int model; switch (def-type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: -if (STREQ(domainDef-os.arch, ppc64) -STREQ(domainDef-os.machine, pseries)) { -virBufferAddLit(buf, spapr-vscsi); -} else { +model = def-model; +if (model == -1 || +model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO) { +model = qemuDefaultScsiControllerModel(domainDef); +} +switch (model) { +case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: virBufferAddLit(buf, lsi); +break; +case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI: +virBufferAddLit(buf, spapr-vscsi); +break; +default: +qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, +_(Unsupported controller model: %s), + virDomainControllerModelSCSITypeToString(def-model)); } virBufferAsprintf(buf, ,id=scsi%d, def-idx); break; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 5a1aebd..5eb7acb 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -490,7 +490,8 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST, buslogic,
[libvirt] [PATCH 0/7 v2] virtio-scsi: New device address logic for SCSI devices
This patch series completed the support for the first 3 parts of Paolo's proposal: http://permalink.gmane.org/gmane.comp.emulators.libvirt/50428 The 3 parts are: * SCSI controller models * Stable addressing for SCSI devices * LUN passthrough: block devices [PATCH 1/10] and [PATCH 2/10] add two new scsi controllers, ibmvscsi and virtio-scsi. [PATCH 3/10] adds a helper functions to get a disk controller's model. [PATCH 4/10] introduces attribute target for device addressing XML. Updates lots of tests to be consistent with the newly introduced attribute. [PATCH 6/10] builds the qemu command line for the new addressing format. The logic is: 1) If the disk controller model is lsilogic: -drive file=/dev/sda,if=none,id=drive-scsi0-0-3,\ format=raw -device scsi-disk,bus=scsi0.0,\ scsi-id=0,drive=drive-scsi0-0-3-0,id=scsi0-0-3-0 libvirt attrs -- qdev properties: bus=scsicontroller.0 scsi-id=unit 2) If the disk controller model is other else: The command line will be like: -drive file=/dev/sda,if=none,id=drive-scsi0-0-3-0,\ format=raw -device scsi-disk,bus=scsi0.0,channel=0,\ scsi-id=3,lun=0,drive=drive-scsi0-0-3-0,id=scsi0-0-3-0 libvirt attrs -- qdev properties: bus=scsicontroller.0 channel=bus scsi-id=target lun=unit Paolo Bonzini (2) qemu: add ibmvscsi controller model qemu: add virtio-scsi controller model Osier Yang (5) conf: Add helper function to look up disk controller conf: Introduce new attribute for device address format qemu: New cap flag to indicate if channel is supported qemu: Build command line for the new address format tests: Add tests for virtio-scsi and ibmvscsi v1 ~ v2: * [PATCH 3/10] is removed * target will be formated to all bus type, once it's device address is of type drive. * Error if target != 0 and the disk bus is not SCSI or the scsi controller model is lsilogic. * [PATCH 9/10] and [PATCH 8/10] are meged into [PATCH 4/7] docs/formatdomain.html.in | 16 ++- docs/schemas/domaincommon.rng | 12 ++ src/conf/domain_conf.c | 38 - src/conf/domain_conf.h |6 + src/libvirt_private.syms |1 + src/qemu/qemu_capabilities.c |4 + src/qemu/qemu_capabilities.h |1 + src/qemu/qemu_command.c| 156 +--- src/qemu/qemu_command.h|7 +- src/qemu/qemu_hotplug.c| 12 +- src/vmx/vmx.c |4 +- tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 12 +- tests/domainsnapshotxml2xmlout/full_domain.xml |2 +- tests/domainsnapshotxml2xmlout/metadata.xml|2 +- tests/qemuxml2argvdata/qemuxml2argv-bios.xml |2 +- .../qemuxml2argvdata/qemuxml2argv-blkdeviotune.xml |4 +- .../qemuxml2argv-blkiotune-device.xml |2 +- tests/qemuxml2argvdata/qemuxml2argv-blkiotune.xml |2 +- tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml |2 +- .../qemuxml2argv-boot-complex-bootindex.xml| 10 +- .../qemuxml2argvdata/qemuxml2argv-boot-complex.xml | 10 +- .../qemuxml2argvdata/qemuxml2argv-boot-floppy.xml |4 +- ...uxml2argv-boot-menu-disable-drive-bootindex.xml |2 +- .../qemuxml2argv-boot-menu-disable-drive.xml |2 +- .../qemuxml2argv-boot-menu-disable.xml |2 +- .../qemuxml2argv-boot-menu-enable.xml |2 +- tests/qemuxml2argvdata/qemuxml2argv-boot-multi.xml |2 +- .../qemuxml2argvdata/qemuxml2argv-boot-network.xml |2 +- tests/qemuxml2argvdata/qemuxml2argv-boot-order.xml |6 +- tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml |2 +- .../qemuxml2argv-channel-guestfwd.xml |2 +- .../qemuxml2argv-channel-spicevmc-old.xml |2 +- .../qemuxml2argv-channel-spicevmc.xml |2 +- .../qemuxml2argv-channel-virtio-auto.xml |2 +- .../qemuxml2argv-channel-virtio.xml|2 +- .../qemuxml2argvdata/qemuxml2argv-clock-france.xml |2 +- .../qemuxml2argv-clock-localtime.xml |2 +- tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml |2 +- .../qemuxml2argv-clock-variable.xml|2 +- .../qemuxml2argv-console-compat-auto.xml |2 +- .../qemuxml2argv-console-compat-chardev.xml|2 +- .../qemuxml2argv-console-compat.xml|2 +- .../qemuxml2argv-console-virtio-many.xml |2 +- .../qemuxml2argv-console-virtio.xml|2 +- tests/qemuxml2argvdata/qemuxml2argv-cputune.xml|2 +- tests/qemuxml2argvdata/qemuxml2argv-disk-aio.xml |4 +- .../qemuxml2argv-disk-cdrom-empty.xml |4 +-
[libvirt] [PATCH 2/7] qemu: add virtio-scsi controller model
From: Paolo Bonzini pbonzini@redhat com Adding a new model for virtio-scsi roughly follows the same scheme as the previous patch. Signed-off-by: Paolo Bonzini pbonzini redhat com --- docs/formatdomain.html.in |2 +- docs/schemas/domaincommon.rng |1 + src/conf/domain_conf.c|3 ++- src/conf/domain_conf.h|1 + src/qemu/qemu_command.c |3 +++ src/vmx/vmx.c |3 ++- 6 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 25f8da5..29497a0 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1658,7 +1658,7 @@ control how many devices can be connected through the controller. A scsi controller has an optional attribute codemodel/code, which is one of auto, buslogic, - ibmvscsi, lsilogic, lsias1068, or vmpvscsi. + ibmvscsi, lsilogic, lsias1068, virtio-scsi or vmpvscsi. A usb controller has an optional attribute codemodel/code, which is one of piix3-uhci, piix4-uhci, ehci, ich9-ehci1, ich9-uhci1, ich9-uhci2, ich9-uhci3, diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index d3deaea..724d7d0 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1121,6 +1121,7 @@ valuelsisas1068/value valuevmpvscsi/value valueibmvscsi/value +valuevirtio-scsi/value valuepiix3-uhci/value valuepiix4-uhci/value valueehci/value diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 18e8b97..93501cf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -239,7 +239,8 @@ VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAS lsilogic, lsisas1068, vmpvscsi, - ibmvscsi); + ibmvscsi, + virtio-scsi); VIR_ENUM_IMPL(virDomainControllerModelUSB, VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST, piix3-uhci, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index aa8c824..777bccb 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -453,6 +453,7 @@ enum virDomainControllerModelSCSI { VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VMPVSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_IBMVSCSI, +VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 90d9948..63f6a05 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2375,6 +2375,9 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef, model = qemuDefaultScsiControllerModel(domainDef); } switch (model) { +case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: +virBufferAddLit(buf, virtio-scsi-pci); +break; case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC: virBufferAddLit(buf, lsi); break; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 5eb7acb..75cb6d1 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -491,7 +491,8 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST, lsilogic, lsisas1068, pvscsi, - UNUSED ibmvscsi); + UNUSED ibmvscsi, + UNUSED virtio-scsi); -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 5/7] qemu: New cap flag to indicate if channel is supported by scsi-disk
--- src/qemu/qemu_capabilities.c |4 src/qemu/qemu_capabilities.h |1 + 2 files changed, 5 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6d35676..64a4546 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -153,6 +153,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, drive-iotune, /* 85 */ system_wakeup, + scsi-disk.channel, ); struct qemu_feature_flags { @@ -1363,6 +1364,7 @@ qemuCapsExtractDeviceStr(const char *qemu, -device, pci-assign,?, -device, virtio-blk-pci,?, -device, virtio-net-pci,?, + -device, scsi-disk,?, NULL); virCommandAddEnvPassCommon(cmd); /* qemu -help goes to stdout, but qemu -device ? goes to stderr. */ @@ -1440,6 +1442,8 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags) qemuCapsSet(flags, QEMU_CAPS_VIRTIO_NET_EVENT_IDX); if (strstr(str, virtio-blk-pci.scsi)) qemuCapsSet(flags, QEMU_CAPS_VIRTIO_BLK_SCSI); +if (strstr(str, scsi-disk.channel)) +qemuCapsSet(flags, QEMU_CAPS_SCSI_DISK_CHANNEL); return 0; } diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index b9666e1..db584ce 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -121,6 +121,7 @@ enum qemuCapsFlags { QEMU_CAPS_FSDEV_WRITEOUT = 84, /* -fsdev writeout supported */ QEMU_CAPS_DRIVE_IOTUNE = 85, /* -drive bps= and friends */ QEMU_CAPS_WAKEUP = 86, /* system_wakeup monitor command */ +QEMU_CAPS_SCSI_DISK_CHANNEL = 87, /* Is scsi-disk.channel available? */ QEMU_CAPS_LAST, /* this must always be the last item */ }; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 6/7] qemu: Build command line for the new address format
For any disk controller model which is not lsilogic, the command line will be like: -drive file=/dev/sda,if=none,id=drive-scsi0-0-3-0,format=raw \ -device scsi-disk,bus=scsi0.0,channel=0,scsi-id=3,lun=0,i\ drive=drive-scsi0-0-3-0,id=scsi0-0-3-0 The relationship between the libvirt address attrs and the qdev properties are (controller model is not lsilogic; strings inside represent libvirt adress attrs): bus=scsicontroller.0 channel=bus scsi-id=target lun=unit * src/qemu/qemu_command.h: (New param virDomainDefPtr def for function qemuBuildDriveDevStr; new param virDomainDefPtr vmdef for function qemuAssignDeviceDiskAlias. Both for virDomainDiskFindControllerModel's use). * src/qemu/qemu_command.c: - New param virDomainDefPtr def for qemuAssignDeviceDiskAliasCustom. For virDomainDiskFindControllerModel's use, if the disk bus is scsi and the controller model is not lsilogic, target is one part of the alias name. - According change on qemuAssignDeviceDiskAlias and qemuBuildDriveDevStr * src/qemu/qemu_hotplug.c: - Changes to be consistent with declarations of qemuAssignDeviceDiskAlias qemuBuildDriveDevStr, and qemuBuildControllerDevStr. * tests/qemuxml2argvdata/qemuxml2argv-pseries-vio-user-assigned.args, tests/qemuxml2argvdata/qemuxml2argv-pseries-vio.args: Update the generated command line. --- src/qemu/qemu_command.c| 124 +--- src/qemu/qemu_command.h|7 +- src/qemu/qemu_hotplug.c| 12 +- .../qemuxml2argv-pseries-vio-user-assigned.args| 13 ++- .../qemuxml2argvdata/qemuxml2argv-pseries-vio.args | 13 ++- 5 files changed, 142 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 63f6a05..58a1d80 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -472,15 +472,39 @@ qemuDefaultScsiControllerModel(virDomainDefPtr def) { } /* Our custom -drive naming scheme used with id= */ -static int qemuAssignDeviceDiskAliasCustom(virDomainDiskDefPtr disk) +static int +qemuAssignDeviceDiskAliasCustom(virDomainDefPtr def, +virDomainDiskDefPtr disk) { const char *prefix = virDomainDiskBusTypeToString(disk-bus); +int controllerModel = -1; + if (disk-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) { -if (virAsprintf(disk-info.alias, %s%d-%d-%d, prefix, -disk-info.addr.drive.controller, -disk-info.addr.drive.bus, -disk-info.addr.drive.unit) 0) -goto no_memory; +if (disk-bus == VIR_DOMAIN_DISK_BUS_SCSI) { +controllerModel = +virDomainDiskFindControllerModel(def, disk, + VIR_DOMAIN_CONTROLLER_TYPE_SCSI); +} + +if (controllerModel == -1 || +controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO) +controllerModel = qemuDefaultScsiControllerModel(def); + +if (disk-bus != VIR_DOMAIN_DISK_BUS_SCSI || +controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) { +if (virAsprintf(disk-info.alias, %s%d-%d-%d, prefix, +disk-info.addr.drive.controller, +disk-info.addr.drive.bus, +disk-info.addr.drive.unit) 0) +goto no_memory; +} else { +if (virAsprintf(disk-info.alias, %s%d-%d-%d-%d, prefix, +disk-info.addr.drive.controller, +disk-info.addr.drive.bus, +disk-info.addr.drive.target, +disk-info.addr.drive.unit) 0) +goto no_memory; +} } else { int idx = virDiskNameToIndex(disk-dst); if (virAsprintf(disk-info.alias, %s-disk%d, prefix, idx) 0) @@ -496,11 +520,13 @@ no_memory: int -qemuAssignDeviceDiskAlias(virDomainDiskDefPtr def, virBitmapPtr qemuCaps) +qemuAssignDeviceDiskAlias(virDomainDefPtr vmdef, + virDomainDiskDefPtr def, + virBitmapPtr qemuCaps) { if (qemuCapsGet(qemuCaps, QEMU_CAPS_DRIVE)) { if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) -return qemuAssignDeviceDiskAliasCustom(def); +return qemuAssignDeviceDiskAliasCustom(vmdef, def); else return qemuAssignDeviceDiskAliasFixed(def); } else { @@ -611,7 +637,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virBitmapPtr qemuCaps) int i; for (i = 0; i def-ndisks ; i++) { -if (qemuAssignDeviceDiskAlias(def-disks[i], qemuCaps) 0) +if (qemuAssignDeviceDiskAlias(def, def-disks[i], qemuCaps) 0) return -1; } if (qemuCapsGet(qemuCaps, QEMU_CAPS_NET_NAME) || @@ -1841,6 +1867,11 @@ qemuBuildDriveStr(virConnectPtr conn
[libvirt] [PATCH 1/3] virsh: Two new helper functions for disk device changes
vshFindDisk is to find the disk node in xml doc with given source path or target of disk device, and type (indicates disk type, normal disk or changeable disk). vshPrepareDiskXML is to make changes on the disk node (e.g. create and insert the new source node for inserting media of CDROM drive). They are marked as unused temporarily. --- tools/virsh.c | 215 + 1 files changed, 215 insertions(+), 0 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 66bbb0c..b65114f 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -14321,6 +14321,221 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) return functionReturn; } +typedef enum { +VSH_FIND_DISK_NORMAL, +VSH_FIND_DISK_CHANGEABLE, +} vshFindDiskType; + +/* Helper function to find disk device in XML doc. Returns the disk + * node on success, or NULL on failure. Caller must free the result + * @path: Fully-qualified path or target of disk device. + * @type: Either VSH_FIND_DISK_NORMAL or VSH_FIND_DISK_CHANGEABLE. + */ +ATTRIBUTE_UNUSED +static xmlNodePtr +vshFindDisk(const char *doc, +const char *path, +int type) +{ +xmlDocPtr xml = NULL; +xmlXPathObjectPtr obj= NULL; +xmlXPathContextPtr ctxt = NULL; +xmlNodePtr cur = NULL; +xmlNodePtr ret = NULL; +int i = 0; + +xml = virXMLParseStringCtxt(doc, _((domain_definition)), ctxt); +if (!xml) { +vshError(NULL, %s, _(Failed to get disk information)); +goto cleanup; +} + +obj = xmlXPathEval(BAD_CAST /domain/devices/disk, ctxt); +if ((obj == NULL) || +(obj-type != XPATH_NODESET) || +(obj-nodesetval == NULL) || +(obj-nodesetval-nodeNr == 0)) { +vshError(NULL, %s, _(Failed to get disk information)); +goto cleanup; +} + +/* search disk using @path */ +for (; i obj-nodesetval-nodeNr; i++) { +bool is_supported = true; + +if (type == VSH_FIND_DISK_CHANGEABLE) { +xmlNodePtr n = obj-nodesetval-nodeTab[i]; +is_supported = false; + +/* Check if the disk is CDROM or floppy disk */ +if (xmlStrEqual(n-name, BAD_CAST disk)) { +char *device_value = virXMLPropString(n, device); + +if (STREQ(device_value, cdrom) || +STREQ(device_value, floppy)) +is_supported = true; + +VIR_FREE(device_value); +} + +if (!is_supported) +continue; +} + +cur = obj-nodesetval-nodeTab[i]-children; +while (cur != NULL) { +if (cur-type == XML_ELEMENT_NODE) { +char *tmp = NULL; + +if (xmlStrEqual(cur-name, BAD_CAST source)) { +if ((tmp = virXMLPropString(cur, file)) || +(tmp = virXMLPropString(cur, dev)) || +(tmp = virXMLPropString(cur, dir)) || +(tmp = virXMLPropString(cur, name))) { +} +} else if (xmlStrEqual(cur-name, BAD_CAST target)) { +tmp = virXMLPropString(cur, dev); +} + +if (STREQ_NULLABLE(tmp, path)) { +ret = xmlCopyNode(obj-nodesetval-nodeTab[i], 1); +VIR_FREE(tmp); +goto cleanup; +} +VIR_FREE(tmp); +} +cur = cur-next; +} +} + +vshError(NULL, _(No found disk whose source path or target is %s), path); + +cleanup: +xmlXPathFreeObject(obj); +xmlXPathFreeContext(ctxt); +xmlFreeDoc(xml); +return ret; +} + +typedef enum { +VSH_PREPARE_DISK_XML_NONE = 0, +VSH_PREPARE_DISK_XML_EJECT, +VSH_PREPARE_DISK_XML_INSERT, +VSH_PREPARE_DISK_XML_UPDATE, +} vshPrepareDiskXMLType; + +/* Helper function to prepare disk XML. Could be used for disk + * detaching, media changing(ejecting, inserting, updating) + * for changeable disk. Returns the processed XML as string on + * success, or NULL on failure. Caller must free the result. + */ +ATTRIBUTE_UNUSED +static char * +vshPrepareDiskXML(xmlNodePtr disk_node, + const char *source, + const char *path, + int type) +{ +xmlNodePtr cur = NULL; +xmlBufferPtr xml_buf = NULL; +const char *disk_type = NULL; +const char *device_type = NULL; +xmlNodePtr new_node = NULL; +char *ret = NULL; + +if (!disk_node) +return NULL; + +xml_buf = xmlBufferCreate(); +if (!xml_buf) { +vshError(NULL, %s, _(Failed to allocate memory)); +return NULL; +} + +device_type = virXMLPropString(disk_node, device); + +if (STREQ_NULLABLE(device_type, cdrom) || +STREQ_NULLABLE(device_type, floppy)) { +bool has_source = false; +disk_type = virXMLPropString(disk_node, type); + +cur = disk_node-children;
[libvirt] [PATCH 0/3 v4] New command for changing media
[PATCH 0/3] introduces two new helper functions: vshFindDisk is to find the disk XML node in xml doc with the type (indicates it's normal disk or changeable disk). VshPrepareDiskXML is to prepare the disk XML for disk changing commands' use, such as detach-disk. The purpose of this patch is to prepare for upcoming new command change-disk, which will use the two helper functions too. Please see [PATCH 3/3] for a overall description of the new command. v2 - v3 * Update vshFindDisk to support search the disk node with both the source path and target name. * Change names of the two new enums ([PATCH 1/3]). * Use virXMLParseStringCtxt instead of xmlReadDoc * Use VIR_ALLOC_N instead of vshCalloc. * [PATCH 3/4] and [PATCH 4/4] are merged into [PATCH 3/3] * Change option --target into --path. * Defaults to use --update if none of --eject, --insert, and --update is specified. * Update docs to be consistent with the changes on codes. * Other nits. v3 - v4: * No changes. Osier Yang (3) virsh: Two new helper functions for disk device changes virsh: Use vshFindDisk and vshPrepareDiskXML in virsh: New command cmdChangeMedia tools/virsh.c | 418 --- tools/virsh.pod | 33 - 2 files changed, 395 insertions(+), 56 deletions(-) Regards, Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] virsh: Use vshFindDisk and vshPrepareDiskXML in cmdDetachDisk
The first use of the two new helper functions. --- tools/virsh.c | 65 1 files changed, 10 insertions(+), 55 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index b65114f..eeb2426 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -14331,7 +14331,6 @@ typedef enum { * @path: Fully-qualified path or target of disk device. * @type: Either VSH_FIND_DISK_NORMAL or VSH_FIND_DISK_CHANGEABLE. */ -ATTRIBUTE_UNUSED static xmlNodePtr vshFindDisk(const char *doc, const char *path, @@ -14429,7 +14428,6 @@ typedef enum { * for changeable disk. Returns the processed XML as string on * success, or NULL on failure. Caller must free the result. */ -ATTRIBUTE_UNUSED static char * vshPrepareDiskXML(xmlNodePtr disk_node, const char *source, @@ -14555,18 +14553,14 @@ static const vshCmdOptDef opts_detach_disk[] = { static bool cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) { -xmlDocPtr xml = NULL; -xmlXPathObjectPtr obj=NULL; -xmlXPathContextPtr ctxt = NULL; -xmlNodePtr cur = NULL; -xmlBufferPtr xml_buf = NULL; +char *disk_xml = NULL; virDomainPtr dom = NULL; const char *target = NULL; char *doc; -int i = 0, diff_tgt; int ret; bool functionReturn = false; unsigned int flags; +xmlNodePtr disk_node = NULL; if (!vshConnectionUsability(ctl, ctl-conn)) goto cleanup; @@ -14581,60 +14575,22 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) if (!doc) goto cleanup; -xml = virXMLParseStringCtxt(doc, _((domain_definition)), ctxt); -VIR_FREE(doc); -if (!xml) { -vshError(ctl, %s, _(Failed to get disk information)); -goto cleanup; -} - -obj = xmlXPathEval(BAD_CAST /domain/devices/disk, ctxt); -if ((obj == NULL) || (obj-type != XPATH_NODESET) || -(obj-nodesetval == NULL) || (obj-nodesetval-nodeNr == 0)) { -vshError(ctl, %s, _(Failed to get disk information)); -goto cleanup; -} - -/* search target */ -for (; i obj-nodesetval-nodeNr; i++) { -cur = obj-nodesetval-nodeTab[i]-children; -while (cur != NULL) { -if (cur-type == XML_ELEMENT_NODE -xmlStrEqual(cur-name, BAD_CAST target)) { -char *tmp_tgt = virXMLPropString(cur, dev); -diff_tgt = STREQ(tmp_tgt, target); -VIR_FREE(tmp_tgt); -if (diff_tgt) { -goto hit; -} -} -cur = cur-next; -} -} -vshError(ctl, _(No found disk whose target is %s), target); -goto cleanup; - - hit: -xml_buf = xmlBufferCreate(); -if (!xml_buf) { -vshError(ctl, %s, _(Failed to allocate memory)); +if (!(disk_node = vshFindDisk(doc, target, VSH_FIND_DISK_NORMAL))) goto cleanup; -} -if (xmlNodeDump(xml_buf, xml, obj-nodesetval-nodeTab[i], 0, 0) 0) { -vshError(ctl, %s, _(Failed to create XML)); +if (!(disk_xml = vshPrepareDiskXML(disk_node, NULL, NULL, + VSH_PREPARE_DISK_XML_NONE))) goto cleanup; -} if (vshCommandOptBool(cmd, persistent)) { flags = VIR_DOMAIN_AFFECT_CONFIG; if (virDomainIsActive(dom) == 1) flags |= VIR_DOMAIN_AFFECT_LIVE; ret = virDomainDetachDeviceFlags(dom, - (char *)xmlBufferContent(xml_buf), + disk_xml, flags); } else { -ret = virDomainDetachDevice(dom, (char *)xmlBufferContent(xml_buf)); +ret = virDomainDetachDevice(dom, disk_xml); } if (ret != 0) { @@ -14645,10 +14601,9 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) } cleanup: -xmlXPathFreeObject(obj); -xmlXPathFreeContext(ctxt); -xmlFreeDoc(xml); -xmlBufferFree(xml_buf); +xmlFreeNode(disk_node); +VIR_FREE(disk_xml); +VIR_FREE(doc); if (dom) virDomainFree(dom); return functionReturn; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/3] virsh: New command cmdChangeMedia
One could use it to eject, insert, or update media of the CDROM or floppy drive. See the documents for more details. --- tools/virsh.c | 142 +++ tools/virsh.pod | 33 - 2 files changed, 172 insertions(+), 3 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index eeb2426..11aa042 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -14610,6 +14610,147 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) } /* + * change-media command + */ +static const vshCmdInfo info_change_media[] = { +{help, N_(Change media of CD or floppy drive)}, +{desc, N_(Change media of CD or floppy drive.)}, +{NULL, NULL} +}; + +static const vshCmdOptDef opts_change_media[] = { +{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)}, +{path, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified path or +target of disk device)}, +{source, VSH_OT_DATA, 0, N_(source of the media)}, +{eject, VSH_OT_BOOL, 0, N_(Eject the media)}, +{insert, VSH_OT_BOOL, 0, N_(Insert the media)}, +{update, VSH_OT_BOOL, 0, N_(Update the media)}, +{current, VSH_OT_BOOL, 0, N_(can be either or both of --live and --config, + depends on implementation of hypervisor driver)}, +{live, VSH_OT_BOOL, 0, N_(alter live configuration of running domain)}, +{config, VSH_OT_BOOL, 0, N_(alter persistent configuration, effect observed on next boot)}, +{force, VSH_OT_BOOL, 0, N_(force media insertion)}, +{NULL, 0, 0, NULL} +}; + +static bool +cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) +{ +virDomainPtr dom = NULL; +const char *source = NULL; +const char *path = NULL; +const char *doc = NULL; +xmlNodePtr disk_node = NULL; +const char *disk_xml = NULL; +int flags = 0; +int config, live, current, force = 0; +int eject, insert, update = 0; +bool ret = false; +int prepare_type = 0; +const char *action = NULL; + +config = vshCommandOptBool(cmd, config); +live = vshCommandOptBool(cmd, live); +current = vshCommandOptBool(cmd, current); +force = vshCommandOptBool(cmd, force); +eject = vshCommandOptBool(cmd, eject); +insert = vshCommandOptBool(cmd, insert); +update = vshCommandOptBool(cmd, update); + +if ((eject insert) || +(insert update) || +(eject update)) { +vshError(ctl, %s, _(--eject, --insert, and --update must be specified +exclusively.)); +return false; +} + +if (eject) { +prepare_type = VSH_PREPARE_DISK_XML_EJECT; +action = eject; +} + +if (insert) { +prepare_type = VSH_PREPARE_DISK_XML_INSERT; +action = insert; +} + +if (update) { +prepare_type = VSH_PREPARE_DISK_XML_UPDATE; +action = update; +} + +/* Defaults to update */ +if (!eject !insert !update) { +prepare_type = VSH_PREPARE_DISK_XML_UPDATE; +action = update; +} + +if (current) { +if (live || config) { +vshError(ctl, %s, _(--current must be specified exclusively)); +return false; +} +flags = VIR_DOMAIN_AFFECT_CURRENT; +} else { +if (config) +flags |= VIR_DOMAIN_AFFECT_CONFIG; +if (live) +flags |= VIR_DOMAIN_AFFECT_LIVE; +} + +if (force) +flags |= VIR_DOMAIN_DEVICE_MODIFY_FORCE; + +if (!vshConnectionUsability(ctl, ctl-conn)) +goto cleanup; + +if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) +goto cleanup; + +if (vshCommandOptString(cmd, path, path) = 0) +goto cleanup; + +if (vshCommandOptString(cmd, source, source) 0) +goto cleanup; + +if (insert !source) { +vshError(ctl, %s, _(No disk source specified for inserting)); +goto cleanup; +} + +if (flags VIR_DOMAIN_AFFECT_CONFIG) +doc = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE); +else +doc = virDomainGetXMLDesc(dom, 0); +if (!doc) +goto cleanup; + +if (!(disk_node = vshFindDisk(doc, path, VSH_FIND_DISK_CHANGEABLE))) +goto cleanup; + +if (!(disk_xml = vshPrepareDiskXML(disk_node, source, path, prepare_type))) +goto cleanup; + +if (virDomainUpdateDeviceFlags(dom, disk_xml, flags) != 0) { +vshError(ctl, _(Failed to %s media), action); +goto cleanup; +} + +vshPrint(ctl, _(succeeded to %s media\n), action); +ret = true; + +cleanup: +VIR_FREE(doc); +xmlFreeNode(disk_node); +VIR_FREE(disk_xml); +if (dom) +virDomainFree(dom); +return ret; +} + +/* * cpu-compare command */ static const vshCmdInfo info_cpu_compare[] = { @@ -16705,6 +16846,7 @@ static const vshCmdDef domManagementCmds[] = { #ifndef WIN32 {console, cmdConsole, opts_console, info_console, 0}, #endif +{change-media,
Re: [libvirt] [PATCH] BlockJob: Support sync/async virDomainBlockJobAbort
On Fri, Jan 13, 2012 at 8:51 PM, Adam Litke a...@us.ibm.com wrote: Qemu has changed the semantics of the block_job_cancel API. Originally, the operation was synchronous (ie. upon command completion, the operation was guaranteed to be completely stopped). With the new semantics, a block_job_cancel merely requests that the operation be cancelled and an event is triggered once the cancellation request has been honored. To adopt the new semantics while preserving compatibility I propose the following updates to the virDomainBlockJob API: A new block job event type VIR_DOMAIN_BLOCK_JOB_CANCELLED will be recognized by libvirt. Regardless of the flags used with virDomainBlockJobAbort, this event will be raised whenever it is received from qemu. This event indicates that a block job has been successfully cancelled. A new extension flag VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC will be added to the virDomainBlockJobAbort API. When enabled, this function will operate asynchronously (ie, it can return before the job has actually been cancelled). When the API is used in this mode, it is the responsibility of the caller to wait for a VIR_DOMAIN_BLOCK_JOB_CANCELLED event or poll via the virDomainGetBlockJobInfo API to check the cancellation status. Without the VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag, libvirt will internally poll using qemu's query-block-jobs API and will not return until the operation has been completed. API users are advised that this operation is unbounded and further interaction with the domain during this period may block. This patch implements the new event type, the API flag, and the polling. The main outstanding issue is whether we should bound the amount of time we will wait for cancellation and return an error. Comments on this proposal? Hi, What's the latest thinking on this issue? I'm happy to help come up with an acceptable patch. I found Adam's initial approach plus suggested cleanups fine. Would that be accepted? Stefan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 3/3] qemu: Implement virDomainPMWakeup API
On 25.02.2012 01:31, Eric Blake wrote: On 02/23/2012 01:44 AM, Michal Privoznik wrote: On 15.02.2012 16:04, Michal Privoznik wrote: using 'system-wakeup' monitor command. It is supported only in JSON, as we are enabling it if possible. Moreover, this command is available in qemu-1.1+ which definitely has JSON. --- src/qemu/qemu_driver.c | 55 ++ src/qemu/qemu_monitor.c | 19 ++ src/qemu/qemu_monitor.h |2 + src/qemu/qemu_monitor_json.c | 21 src/qemu/qemu_monitor_json.h |2 + 5 files changed, 99 insertions(+), 0 deletions(-) Ping? Eric, it seems to me like you've forgotten this last patch. Indeed, it fell off my stack of most-recently-pinged patches. Reviewing now, and thanks for the ping... using 'system-wakeup' monitor command. It is supported only in JSON, as we are enabling it if possible. Moreover, this command is available in qemu-1.1+ which definitely has JSON. --- src/qemu/qemu_driver.c | 55 ++ src/qemu/qemu_monitor.c | 19 ++ src/qemu/qemu_monitor.h |2 + src/qemu/qemu_monitor_json.c | 21 src/qemu/qemu_monitor_json.h |2 + 5 files changed, 99 insertions(+), 0 deletions(-) +static int qemuDomainPMWakeup(virDomainPtr dom, + unsigned int flags) Style nit - we aren't very consistent on whether function names begin on line 1, but qemu_driver tends to use: static int qemuDomainPMWakeup(virDomainPtr dom, unsigned int flags) +++ b/src/qemu/qemu_monitor_json.c @@ -3492,3 +3492,24 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon, virJSONValueFree(result); return ret; } + +int qemuMonitorJSONSystemWakeup(qemuMonitorPtr mon) +{ +int ret = -1; +virJSONValuePtr cmd = NULL; +virJSONValuePtr reply = NULL; + +cmd = qemuMonitorJSONMakeCommand(system_wakeup, NULL); Seems so simple :) ACK. Thanks for review. Fixed all nits and pushed; Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v5 0/7] Console corruption patchset
On 02/25/2012 01:27 AM, Eric Blake wrote: On 02/23/2012 07:03 AM, Peter Krempa wrote: Yet another spin of the console corruption patches. ACK series if you make some changes to 6/7. At this point, I don't know if we're going to get a timely review from Dan, so I'm comfortable pushing into the tree now to lengthen the testing time we can give this prior to the 0.9.11 freeze. Thanks; I made the requested changes, tested the build and pushed. Peter -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [virsh] [PATCH BZ#732364] please add a .virsh/rc file
Hi, libvirt developers I found very interesting libvirt and i wrote patch for BZ#732264 I added support for parsing ~/.virsh/rc file. rc file in format KEY = VALUE symbol '#' - comment Now, only one value added for parsing - VIRSH_DEFAULT_CONNECT_URI. This value can be overwrite by env variable VIRSH_DEFAULT_CONNECT_URI. Thanks P.S. How to add patch file? As attached file or in mail body? P.P.S. I am using irc, my nick - fenksa --- diff --git a/tools/virsh.c b/tools/virsh.c index e712e53..8360c57 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -33,6 +33,7 @@ #include signal.h #include poll.h #include strings.h +#include pwd.h #include libxml/parser.h #include libxml/tree.h @@ -19313,6 +19314,132 @@ vshParseArgv(vshControl *ctl, int argc, char **argv) return true; } +#define DEFAULT_RC_FILENAME .virsh/rc + +static const char* +vshRcPath(vshControl* ctl) { +const char* home; +char* path; + +home = virGetUserDirectory(getuid()); +path = vshMalloc(ctl, strlen(home) + strlen(DEFAULT_RC_FILENAME) + 2); + +memcpy(path, home, strlen(home)); +path[strlen(home)] = '/'; +memcpy(path + strlen(home) + 1, DEFAULT_RC_FILENAME, strlen(DEFAULT_RC_FILENAME)); + +VIR_FREE(home); + +return path; +} + +typedef struct { +char* buf; +int len; +int p; +} RcParseBuffer; + +static void +vshClearRcParseBuffer(RcParseBuffer* buf) { +buf-p = 0; +bzero(buf-buf, buf-len); +} + +static void +vshInitRcParseBuffer(vshControl* ctl, RcParseBuffer* buf, int len) { +buf-buf = vshMalloc(ctl, len); +buf-len = len; +vshClearRcParseBuffer(buf); +}; + +static void +vshAddCharRcParseBuffer(RcParseBuffer* buf, char ch) { +if (buf-p buf-len) { +buf-buf[buf-p] = ch; +buf-p = buf-p + 1; +} +} + +static void +vshParseRc(vshControl *ctl) +{ +int fd; +const char* fileName = vshRcPath(ctl); +bool parseValue = false; + +RcParseBuffer keyBuffer; +RcParseBuffer valueBuffer; +char buffer[1024]; + +vshInitRcParseBuffer(ctl, keyBuffer, 255); +vshInitRcParseBuffer(ctl, valueBuffer, 255); + +/* open ~/.virsh/rc file */ +if ((fd = open(fileName, O_RDONLY)) = 0) { +vshDebug(ctl, VSH_ERR_INFO, can't open file %s\n, fileName); +goto cleanup; +} + +struct stat statBuf; +if (fstat(fd, statBuf) == -1) { +vshDebug(ctl, VSH_ERR_INFO, file %s not stated\n, fileName); +goto cleanup; +} + +if (!S_ISREG(statBuf.st_mode)) { +vshError(ctl, _(file %s is not regular\n), fileName); +goto cleanup; +} + +int bytesRead; +while ((bytesRead = read(fd, buffer, sizeof(buffer))) 0) { +for (int i = 0; i bytesRead; i++) { +/* ignore empty spaces and comments */ +if (buffer[i] == ' ' || buffer[i] == '#') { + continue; +} + +/* found separator = */ +if (buffer[i] == '=') { +if (!parseValue) { +parseValue = true; +continue; +} +} + +/* end of line*/ +if (buffer[i] == '\n') { +if (STREQ(keyBuffer.buf, VIRSH_DEFAULT_CONNECT_URI)) { +ctl-name = vshStrdup(ctl, valueBuffer.buf); +} + +vshClearRcParseBuffer(keyBuffer); +vshClearRcParseBuffer(valueBuffer); + +parseValue = false; +continue; +} + +if (parseValue) { +vshAddCharRcParseBuffer(valueBuffer, buffer[i]); +} else { +vshAddCharRcParseBuffer(keyBuffer, buffer[i]); +} +} +} + +cleanup: +if (fd = 0) { +if (close(fd) 0) { +vshError(ctl, _(cannot close file %s), fileName); +} +} +VIR_FREE(fileName); +VIR_FREE(keyBuffer.buf); +VIR_FREE(valueBuffer.buf); +} + + int main(int argc, char **argv) { @@ -19355,6 +19482,8 @@ main(int argc, char **argv) else progname++; +vshParseRc(ctl); + if ((defaultConn = getenv(VIRSH_DEFAULT_CONNECT_URI))) { ctl-name = vshStrdup(ctl, defaultConn); } -- With best wishes, Maxim Sditanov tools_virsh.c.patch Description: Binary data -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [virsh] [PATCH BZ#732364] please add a .virsh/rc file
Hi, libvirt developers I found very interesting libvirt and i wrote patch for BZ#732264 I added support for parsing ~/.virsh/rc file. rc file in format KEY = VALUE symbol '#' - comment Now, only one value added for parsing - VIRSH_DEFAULT_CONNECT_URI. This value can be overwrite by env variable VIRSH_DEFAULT_CONNECT_URI. Thanks P.S. How to add patch file? As attached file or in mail body? P.P.S. I am using irc, my nick - fenksa --- diff --git a/tools/virsh.c b/tools/virsh.c index e712e53..8360c57 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -33,6 +33,7 @@ #include signal.h #include poll.h #include strings.h +#include pwd.h #include libxml/parser.h #include libxml/tree.h @@ -19313,6 +19314,132 @@ vshParseArgv(vshControl *ctl, int argc, char **argv) return true; } +#define DEFAULT_RC_FILENAME .virsh/rc + +static const char* +vshRcPath(vshControl* ctl) { +const char* home; +char* path; + +home = virGetUserDirectory(getuid()); +path = vshMalloc(ctl, strlen(home) + strlen(DEFAULT_RC_FILENAME) + 2); + +memcpy(path, home, strlen(home)); +path[strlen(home)] = '/'; +memcpy(path + strlen(home) + 1, DEFAULT_RC_FILENAME, strlen(DEFAULT_RC_FILENAME)); + +VIR_FREE(home); + +return path; +} + +typedef struct { +char* buf; +int len; +int p; +} RcParseBuffer; + +static void +vshClearRcParseBuffer(RcParseBuffer* buf) { +buf-p = 0; +bzero(buf-buf, buf-len); +} + +static void +vshInitRcParseBuffer(vshControl* ctl, RcParseBuffer* buf, int len) { +buf-buf = vshMalloc(ctl, len); +buf-len = len; +vshClearRcParseBuffer(buf); +}; + +static void +vshAddCharRcParseBuffer(RcParseBuffer* buf, char ch) { +if (buf-p buf-len) { +buf-buf[buf-p] = ch; +buf-p = buf-p + 1; +} +} + +static void +vshParseRc(vshControl *ctl) +{ +int fd; +const char* fileName = vshRcPath(ctl); +bool parseValue = false; + +RcParseBuffer keyBuffer; +RcParseBuffer valueBuffer; +char buffer[1024]; + +vshInitRcParseBuffer(ctl, keyBuffer, 255); +vshInitRcParseBuffer(ctl, valueBuffer, 255); + +/* open ~/.virsh/rc file */ +if ((fd = open(fileName, O_RDONLY)) = 0) { +vshDebug(ctl, VSH_ERR_INFO, can't open file %s\n, fileName); +goto cleanup; +} + +struct stat statBuf; +if (fstat(fd, statBuf) == -1) { +vshDebug(ctl, VSH_ERR_INFO, file %s not stated\n, fileName); +goto cleanup; +} + +if (!S_ISREG(statBuf.st_mode)) { +vshError(ctl, _(file %s is not regular\n), fileName); +goto cleanup; +} + +int bytesRead; +while ((bytesRead = read(fd, buffer, sizeof(buffer))) 0) { +for (int i = 0; i bytesRead; i++) { +/* ignore empty spaces and comments */ +if (buffer[i] == ' ' || buffer[i] == '#') { + continue; +} + +/* found separator = */ +if (buffer[i] == '=') { +if (!parseValue) { +parseValue = true; +continue; +} +} + +/* end of line*/ +if (buffer[i] == '\n') { +if (STREQ(keyBuffer.buf, VIRSH_DEFAULT_CONNECT_URI)) { +ctl-name = vshStrdup(ctl, valueBuffer.buf); +} + +vshClearRcParseBuffer(keyBuffer); +vshClearRcParseBuffer(valueBuffer); + +parseValue = false; +continue; +} + +if (parseValue) { +vshAddCharRcParseBuffer(valueBuffer, buffer[i]); +} else { +vshAddCharRcParseBuffer(keyBuffer, buffer[i]); +} +} +} + +cleanup: +if (fd = 0) { +if (close(fd) 0) { +vshError(ctl, _(cannot close file %s), fileName); +} +} +VIR_FREE(fileName); +VIR_FREE(keyBuffer.buf); +VIR_FREE(valueBuffer.buf); +} + + int main(int argc, char **argv) { @@ -19355,6 +19482,8 @@ main(int argc, char **argv) else progname++; +vshParseRc(ctl); + if ((defaultConn = getenv(VIRSH_DEFAULT_CONNECT_URI))) { ctl-name = vshStrdup(ctl, defaultConn); } -- With best wishes, Maxim Sditanov tools_virsh.c.patch Description: Binary data -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [virsh] [PATCH BZ#732364] please add a .virsh/rc file
On Mon, Feb 27, 2012 at 04:56:01PM +0200, Feniks Gordon Freeman wrote: Hi, libvirt developers I found very interesting libvirt and i wrote patch for BZ#732264 I added support for parsing ~/.virsh/rc file. rc file in format KEY = VALUE symbol '#' - comment Now, only one value added for parsing - VIRSH_DEFAULT_CONNECT_URI. This value can be overwrite by env variable VIRSH_DEFAULT_CONNECT_URI. Hmm, I didn't know we had a VIRSH_DEFAULT_CONNECT_URI - we also have LIBVIRT_DEFAULT_CONNECT_URI, which applies to any libvirt app. We also already have a $HOME/.libvirt/libvirt.conf for configuring client apps. I think it'd be better to extend that existing config file so the defaults affect all apsp (eg virt-top, virt-install, etc) - chances are if you want to change one, you want to change them all. And to deprecate usage of VIRSH_DEFAULT_CONNECT_URI too while we're at it. Regards, 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] Per-guest configurable user/group for QEMU processes
Great. I think it is a good approach. The lack of an enclosing tag still bothers me. But, as you said, there's no serious problem not having it and I can live with that :) I believe the primary driver should be defined in qemu.conf, so I would like to replace the security_driver config with two new configs: primary_security_driver and additional_security_drivers. The last one would contain a list of security divers separated by commas, for example: primary_security_driver = apparmor additional_security_divers = dac,another_driver For device seclabel's, I intend to add a model attribute to specify which security driver is being overriding (if it's not given, the primary driver is considered). domain ... ... devices disk type='file' device='disk' source file='/path/to/image1' seclabel relabel='no' model='dac'/ /source ... /disk disk type='file' device='disk' source file='/path/to/image2' seclabel relabel='yes' model=selinux label system_u:object_r:shared_content_t:s0 /label /seclabel /source ... /disk ... /devices seclabel type='dynamic' model='selinux' baselabeltext/baselabel /seclabel seclabel type='static' model='dac' label501:501/label imagelabel501:501/imagelabel /seclabel /domain What do you think? Regards, Marcelo On 02/23/2012 07:34 PM, Daniel P. Berrange wrote: On Thu, Feb 23, 2012 at 06:38:45PM -0200, Marcelo Cerri wrote: On 02/23/2012 05:47 PM, Daniel P. Berrange wrote: On Thu, Feb 23, 2012 at 05:41:27PM -0200, Marcelo Cerri wrote: Hi, I'm starting working on an improvement for libvirt to be able to support per-guest configurable user and group IDs for QEMU processes. Currently, libvirt uses a configurable pair of user and group, which is defined in qemu.conf, for all qemu processes when running in privileged mode. This topic was already commented in qemu mailing list (http://lists.nongnu.org/archive/html/qemu-devel/2011-10/msg00758.html) but, as this requires changes in libvirt API, I'd like to discuss what would be the best solution for it. A solution (as proposed in the link above) would be to extend the security driver model to allow multiple drivers. In this case, an example of the XML definition would be: ... seclabel type='dynamic' model='selinux' labelsystem_u:system_r:svirt_t:s0:c633,c712/label imagelabelsystem_u:object_r:svirt_image_t:s0:c633,c712/imagelabel /seclabel seclabel type='dynamic' model='dac' label102:102/label imagelabel102:102/imagelabel /seclabel ... I don't know if this is a clean solution because the usual option would be to enclose the block above in a seclabels tag. But as this would break the actual API, it's not viable. While it is true that we would ordinarily have an enclosing tag likeseclabels, there's no serious problem not having it. Just having two (or more)seclabel elements in a row is just fine, given our backwards compatibility requirements. So I think this option is just fine. I agree that this is a good solution, considering the XML compatibility. But, what about virDomainGetSecurityLabel? It could access the first security label or ignore the DAC driver (and maybe another function could be added to access the whole list of seclabels), but it doesn't seem to be the best solution. We can just keep virDomainGetSecurityLabel()/virNodeGetSecurityModel as only ever handling the primary security driver. Then add some new APIs which are more general int virNodeGetSecurityModelCount(virConnectPtr conn); int virNodeGetSecurityModelList(virConnectPtr conn, virSecurityModelPtr models, int nmodels); int virDomainGetSecurityLabelList(virDomainptr dom, virSecuriyLabelptr labels, int nlabels); Regards, Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [virsh] [PATCH BZ#732364] please add a .virsh/rc file
As i understand, when libvirt init from application, it parse conf file $HOME/.libvirt/libvirt.conf and set params. Also libvirt have env param LIBVIRT_DEFAULT_CONNECT_URI, which set default connection uri. I will extend libvirt.conf file with default connect uri parameter. Also, i think it will be good idea to make env variable LIBVIRT_DEFAULT_CONNECT_URI higher priority over conf file value (it will be usefull for user scripts). Thanks 2012/2/27 Daniel P. Berrange berra...@redhat.com: On Mon, Feb 27, 2012 at 04:56:01PM +0200, Feniks Gordon Freeman wrote: Hi, libvirt developers I found very interesting libvirt and i wrote patch for BZ#732264 I added support for parsing ~/.virsh/rc file. rc file in format KEY = VALUE symbol '#' - comment Now, only one value added for parsing - VIRSH_DEFAULT_CONNECT_URI. This value can be overwrite by env variable VIRSH_DEFAULT_CONNECT_URI. Hmm, I didn't know we had a VIRSH_DEFAULT_CONNECT_URI - we also have LIBVIRT_DEFAULT_CONNECT_URI, which applies to any libvirt app. We also already have a $HOME/.libvirt/libvirt.conf for configuring client apps. I think it'd be better to extend that existing config file so the defaults affect all apsp (eg virt-top, virt-install, etc) - chances are if you want to change one, you want to change them all. And to deprecate usage of VIRSH_DEFAULT_CONNECT_URI too while we're at it. Regards, 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 :| -- With best wishes, Maxim Sditanov -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib] a leak in libvirt-glib
Hi, In libvirt-glib, we call virStreamEventAddCallback() and give it a ref, that is supposed to be unref when the stream event is removed. But this doesn't happen! I tracked it down to: static void remoteStreamCallbackFree(void *opaque) { struct remoteStreamCallbackData *cbdata = opaque; if (!cbdata-cb cbdata-ff) (cbdata-ff)(cbdata-opaque); Why are we checking for cbdata-cb here? That gives us a leak when taking screenshots. So far I solved it with the attached patch for libvirt-glib. I noticed it because that of a resulting process fd leakage in the libvirtd side. It might be that the fix should be in libvirt, but anyway, the proposed patch doesn't need a libvirt depedency update and also keeps the object reference manangement at the libvirt-glib level, which is nice. -- Marc-André Lureau From e3ff31c92edd2390def3226647681cc7252c1a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= marcandre.lur...@redhat.com Date: Thu, 2 Feb 2012 21:22:42 +0100 Subject: [PATCH libvirt-glib] Don't leak GVirStream Do not give away a reference to virStreamEventAddCallback, but manage stream life-time and event instead. It seems to be a bug in current implementation of libvirt remoteStreamCallbackFree() that doesn't call the free/notify cb for some reason. (even if it did, I am not sure it would work correctly, so I prefer that patch) --- libvirt-gobject/libvirt-gobject-stream.c | 29 ++--- 1 files changed, 18 insertions(+), 11 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-stream.c b/libvirt-gobject/libvirt-gobject-stream.c index a1039b1..5486b95 100644 --- a/libvirt-gobject/libvirt-gobject-stream.c +++ b/libvirt-gobject/libvirt-gobject-stream.c @@ -67,6 +67,7 @@ enum { #define GVIR_STREAM_ERROR gvir_stream_error_quark() +static void gvir_stream_update_events(GVirStream *stream); static GQuark gvir_stream_error_quark(void) @@ -204,13 +205,6 @@ static void gvir_stream_finalize(GObject *object) if (self-priv-input_stream) g_object_unref(self-priv-input_stream); -if (priv-handle) { -if (virStreamFinish(priv-handle) 0) -g_critical(cannot finish stream); - -virStreamFree(priv-handle); -} - tmp = priv-sources; while (tmp) { GVirStreamSource *source = tmp-data; @@ -218,6 +212,16 @@ static void gvir_stream_finalize(GObject *object) tmp = tmp-next; } g_list_free(priv-sources); +priv-sources = NULL; + +if (priv-handle) { +gvir_stream_update_events(self); + +if (virStreamFinish(priv-handle) 0) +g_critical(cannot finish stream); + +virStreamFree(priv-handle); +} G_OBJECT_CLASS(gvir_stream_parent_class)-finalize(object); } @@ -550,8 +554,8 @@ static void gvir_stream_update_events(GVirStream *stream) } else { virStreamEventAddCallback(priv-handle, mask, gvir_stream_handle_events, - g_object_ref(stream), - g_object_unref); + stream, + NULL); priv-eventRegistered = TRUE; } } else { @@ -600,8 +604,9 @@ static void gvir_stream_source_finalize(GSource *source) GVirStreamPrivate *priv = gsource-stream-priv; priv-sources = g_list_remove(priv-sources, source); - gvir_stream_update_events(gsource-stream); + +g_clear_object(gsource-stream); } GSourceFuncs gvir_stream_source_funcs = { @@ -657,12 +662,14 @@ guint gvir_stream_add_watch_full(GVirStream *stream, gpointer opaque, GDestroyNotify notify) { +g_return_val_if_fail(GVIR_IS_STREAM(stream), 0); + GVirStreamPrivate *priv = stream-priv; GVirStreamSource *source = (GVirStreamSource*)g_source_new(gvir_stream_source_funcs, sizeof(GVirStreamSource)); guint ret; -source-stream = stream; +source-stream = g_object_ref(stream); source-cond = cond; if (priority != G_PRIORITY_DEFAULT) -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/7] qemu: Build command line for the new address format
On 02/27/2012 12:59 PM, Osier Yang wrote: +_(target must be 0 for leagacy controller + model 'lsilogic')); Remove (misspelled :)) leagacy. +goto error; +} + +virBufferAddLit(opt, scsi-disk); +virBufferAsprintf(opt, ,bus=scsi%d.%d,scsi-id=%d, + disk-info.addr.drive.controller, + disk-info.addr.drive.bus, + disk-info.addr.drive.unit); +} else { +if (!qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_CHANNEL)) { +if (disk-info.addr.drive.target 7) { +qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, +_(This QEMU doesn't support target + greater than 7)); +goto error; +} + +if ((disk-info.addr.drive.bus != disk-info.addr.drive.unit) +(disk-info.addr.drive.bus != 0)) { +qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, +_(This QEMU only supports both bus and + unit are equal to 0)); Remove are. +goto error; Otherwise the series looks good. Thanks! Paolo -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/7 v2] virtio-scsi: New device address logic for SCSI devices
On 02/27/2012 04:58 AM, Osier Yang wrote: This patch series completed the support for the first 3 parts of Paolo's proposal: http://permalink.gmane.org/gmane.comp.emulators.libvirt/50428 The 3 parts are: * SCSI controller models * Stable addressing for SCSI devices * LUN passthrough: block devices [PATCH 1/10] and [PATCH 2/10] add two new scsi controllers, ibmvscsi and virtio-scsi. You talk about 1/10, but this mail is only 0/7. Am I missing three patches? -- Eric Blake ebl...@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 4/7] conf: Introduce new attribute for device address format
On 02/27/2012 04:58 AM, Osier Yang wrote: * src/conf/domain_conf.h: Add new member target to struct _virDomainDeviceDriveAddress. * src/conf/domain_conf.c: Parse and format target * Lots of tests (.xml) in tests/domainsnapshotxml2xmlout, tests/qemuxml2argvdata, tests/qemuxml2xmloutdata, and tests/vmx2xmldata/ are modified for newly introduced attribute target for address of drive type. --- docs/formatdomain.html.in | 12 ++-- docs/schemas/domaincommon.rng | 10 ++ src/conf/domain_conf.c | 17 + src/conf/domain_conf.h |1 + tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 12 ++-- This modifies existing tests, but I didn't (quickly) see any addition of a new test with a non-zero target. tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml |4 ++-- 194 files changed, 292 insertions(+), 264 deletions(-) Evidence of my claim includes the fact that this patch did not add any new files, and none of the tests added more lines than were removed. @@ -2016,7 +2017,6 @@ virDomainDeviceInfoFormat(virBufferPtr buf, return 0; } - static int virDomainDevicePCIAddressParseXML(xmlNodePtr node, virDomainDevicePCIAddressPtr addr) Spurious whitespace change, but I can live with it. I'm okay if you add an 8/7 with further tests of the new XML (or, I may be surprised by 5-7/7 adding those tests). -- Eric Blake ebl...@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 7/7] tests: Add tests for virtio-scsi and ibmvscsi controllers
On 02/27/2012 04:59 AM, Osier Yang wrote: --- .../qemuxml2argv-disk-scsi-virtio-scsi.args|9 + .../qemuxml2argv-disk-scsi-virtio-scsi.xml | 32 .../qemuxml2argv-disk-scsi-vscsi.args |8 + .../qemuxml2argv-disk-scsi-vscsi.xml | 32 tests/qemuxml2argvtest.c |4 ++ tests/qemuxml2xmltest.c|4 ++- 6 files changed, 88 insertions(+), 1 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.xml OK, I think this fixes most of my comment on 4/7; but I still don't see any non-zero target='1' entries in the new tests. If you fix Paolo's nits, as well as enhance that aspect of the tests, then you have my: ACK series. -- Eric Blake ebl...@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] libxl: eliminate memory leak in libxmlDomainModifyDeviceFlags
On 02/27/2012 04:01 AM, Laine Stump wrote: I found this randomly by examination when a tag search led me to this file. I don't have a setup to test it, but it appears fairly obvious that this call to virDomainDeviceDefParse is both unnecessary (since it will again be called at the top of the immediately following if(), and if not there, then at the top of the if following that), but it also creates a leak of one virDomainDeviceDef and one [whatever type of device the DeviceDef is pointing to; probably a virDomainDiskDef] in the case that the function has been called with VIR_DOMAIN_DEVICE_MODIFY_CONFIG (the second parse will overwrite the devicedef that was just created). --- src/libxl/libxl_driver.c |4 1 files changed, 0 insertions(+), 4 deletions(-) ACK. -- Eric Blake ebl...@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] qemu: fix cleanup of bridge during failure of qemuDomainAttachNetDevice
On 02/25/2012 04:40 PM, Laine Stump wrote: From: Laine Stump la...@redhat.com In qemuDomainAttachNetDevice, the guest's tap interface has only been attached to the bridge if iface_connected is true. It's possible for an error to occur prior to that happening, and previously we would attempt to remove the tap interface from the bridge even if it hadn't been attached. --- src/qemu/qemu_hotplug.c | 11 ++- 1 files changed, 6 insertions(+), 5 deletions(-) ACK - looks like the patch was just the addition of {} followed by reindentation. -- Eric Blake ebl...@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 2/3] virsh: Use vshFindDisk and vshPrepareDiskXML in cmdDetachDisk
On 02/27/2012 05:11 AM, Osier Yang wrote: The first use of the two new helper functions. --- tools/virsh.c | 65 1 files changed, 10 insertions(+), 55 deletions(-) ACK, and nice cleanup. -- Eric Blake ebl...@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/3] virsh: Two new helper functions for disk device changes
On 02/27/2012 05:11 AM, Osier Yang wrote: vshFindDisk is to find the disk node in xml doc with given source path or target of disk device, and type (indicates disk type, normal disk or changeable disk). vshPrepareDiskXML is to make changes on the disk node (e.g. create and insert the new source node for inserting media of CDROM drive). They are marked as unused temporarily. --- tools/virsh.c | 215 + 1 files changed, 215 insertions(+), 0 deletions(-) +if (STREQ_NULLABLE(device_type, cdrom) || +STREQ_NULLABLE(device_type, floppy)) { +bool has_source = false; +disk_type = virXMLPropString(disk_node, type); + +cur = disk_node-children; +while (cur != NULL) { +if (cur-type == XML_ELEMENT_NODE +xmlStrEqual(cur-name, BAD_CAST source)) { +has_source = true; +break; +} +cur = cur-next; +} + +if (!has_source) { +if (type == VSH_PREPARE_DISK_XML_EJECT) { +vshError(NULL, _(The disk device whose source path or target + is '%s' doesn't have media), path); If there is no source, then the disk device was found via target, not source path :) Avoid the problem, as well as making things shorter, by changing the error message to: The disk device '%s' doesn't have media + +if (has_source) { +if (type == VSH_PREPARE_DISK_XML_INSERT) { +vshError(NULL, _(The disk device whose source path or target + is '%s' already has media), path); Along those lines, a consistent error message would be: The disk device '%s' already has media ACK with those nits fixed. -- Eric Blake ebl...@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 3/3] virsh: New command cmdChangeMedia
On 02/27/2012 05:11 AM, Osier Yang wrote: One could use it to eject, insert, or update media of the CDROM or floppy drive. See the documents for more details. s/documents/documentation/ --- tools/virsh.c | 142 +++ tools/virsh.pod | 33 - 2 files changed, 172 insertions(+), 3 deletions(-) +static const vshCmdOptDef opts_change_media[] = { +{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)}, +{path, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified path or +target of disk device)}, +{source, VSH_OT_DATA, 0, N_(source of the media)}, +{eject, VSH_OT_BOOL, 0, N_(Eject the media)}, +{insert, VSH_OT_BOOL, 0, N_(Insert the media)}, +{update, VSH_OT_BOOL, 0, N_(Update the media)}, I still wonder if --mode={eject|insert|update} would have been any easier to code, but that's just painting the bikeshed, so don't worry about it. +static bool +cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) +{ +virDomainPtr dom = NULL; +const char *source = NULL; +const char *path = NULL; +const char *doc = NULL; +xmlNodePtr disk_node = NULL; +const char *disk_xml = NULL; +int flags = 0; +int config, live, current, force = 0; s/int/bool/ +int eject, insert, update = 0; s/int/bool/ +bool ret = false; +int prepare_type = 0; +const char *action = NULL; + +config = vshCommandOptBool(cmd, config); +live = vshCommandOptBool(cmd, live); +current = vshCommandOptBool(cmd, current); +force = vshCommandOptBool(cmd, force); +eject = vshCommandOptBool(cmd, eject); +insert = vshCommandOptBool(cmd, insert); +update = vshCommandOptBool(cmd, update); Particularly since you are assigning all 7 variables from vshCommandOptBool. + +if ((eject insert) || +(insert update) || +(eject update)) { A shorter way to write this: if (eject + insert + update 1) { +vshError(ctl, %s, _(--eject, --insert, and --update must be specified +exclusively.)); +return false; +} + +if (eject) { +prepare_type = VSH_PREPARE_DISK_XML_EJECT; +action = eject; +} + +if (insert) { +prepare_type = VSH_PREPARE_DISK_XML_INSERT; +action = insert; +} + +if (update) { +prepare_type = VSH_PREPARE_DISK_XML_UPDATE; +action = update; +} + +/* Defaults to update */ +if (!eject !insert !update) { +prepare_type = VSH_PREPARE_DISK_XML_UPDATE; +action = update; You can combine these two clauses: if (update || (!eject !insert)) { + +if (virDomainUpdateDeviceFlags(dom, disk_xml, flags) != 0) { +vshError(ctl, _(Failed to %s media), action); Translators won't like this; there are languages where the spelling of the rest of the sentence depends on the gender of the word in 'action'. Better would be: Failed to complete '%s' action on media +goto cleanup; +} + +vshPrint(ctl, _(succeeded to %s media\n), action); and again, better would be: Successfully completed '%s' action on media' @@ -16705,6 +16846,7 @@ static const vshCmdDef domManagementCmds[] = { #ifndef WIN32 {console, cmdConsole, opts_console, info_console, 0}, #endif +{change-media, cmdChangeMedia, opts_change_media, info_change_media, 0}, Sorting - change-media comes _before_ console +++ b/tools/virsh.pod @@ -1490,9 +1490,10 @@ from the domain. =item Bdetach-interface Idomain-id Itype [I--mac mac] Detach a network interface from a domain. -Itype can be either Inetwork to indicate a physical network device or Ibridge to indicate a bridge to a device. -It is recommended to use the Imac option to distinguish between the interfaces -if more than one are present on the domain. +Itype can be either Inetwork to indicate a physical network device or +Ibridge to indicate a bridge to a device. It is recommended to use the +Imac option to distinguish between the interfaces if more than one are +present on the domain. Unrelated hunk; for backport purposes, it would be nicer if you split this cleanup hunk into a separate (pre-approved) patch. =item Bupdate-device Idomain-id Ifile [I--persistent] [I--force] @@ -1503,6 +1504,32 @@ option can be used to force device update, e.g., to eject a CD-ROM even if it is locked/mounted in the domain. See the documentation to learn about libvirt XML format for a device. +=item Bchange-media Idomain-id Ipath [I--eject] [I--insert] +[I--update] [Isource] [I--force] [I--current] [I--live] [I--config] Per convention on other commands, --current is mutually exclusive with --live or --config, so I'd show that part of the line as: [[I--live] [I--config] | [I--current]] ACK with nits fixed, and about time we had this useful command! (I
[libvirt] [PATCH 1/1] lxc: handle shutdown (and detect, but mis-handle reboot)
The -mm tree has Daniel Lezcano's patch changing the handling of sys_reboot in a non-init pidns. That means that, with that support, (a) it is safe to grant CAP_SYS_BOOT to a container, and (b) it's possible to distinguish between reboot and shutdown. I've implemented partial support of this for libvirt in the patch below. If Daniel's patch is not in the running kernel, then CAP_SYS_BOOT will be dropped for the container. Otherwise, it will be kept in. When the container exits, if it was determined to be a shutdown, the container will terminate. However, I didn't know how to properly do the reboot part. The patch below shows how to detect it (and sets the static bool wantreboot to true in that case), but I didn't know quite what to do with that. It looks like the code flow between lxcControllerRun and lxcControllerMain would need to be changed a bit so that we could re-run the lxcContainerStart() without causing the monitor.serverFD (or whichever pipe sends monitor events to lxc_driver.c to trigger autodestroy) to be closed. So for now I'm sending this patch, and hoping the sorcerers on this list can hook reboot up as well, or show the best way how. thanks, -serge Subject: [PATCH 1/1] lxc: handle shutdown (and detect, but mis-handle reboot) If Daniel Lezcano's pidns reboot patch is in the kernel, then don't drop CAP_SYS_BOOT. When container calls shutdown, terminate the container. This patch detects when the container wanted to reboot, but goes ahead and terminates the container because I don't know how to best structure the code to support restarting a container that wanted to reboot. Signed-off-by: Serge Hallyn serge.hal...@canonical.com --- src/lxc/lxc_container.c | 13 -- src/lxc/lxc_container.h |3 +- src/lxc/lxc_controller.c | 97 -- 3 files changed, 103 insertions(+), 10 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index e93fda5..793cb19 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -102,6 +102,7 @@ struct __lxc_child_argv { char **ttyPaths; size_t nttyPaths; int handshakefd; +bool dropreboot; }; @@ -1216,7 +1217,7 @@ static int lxcContainerSetupMounts(virDomainDefPtr vmDef, * It removes some capabilities that could be dangerous to * host system, since they are not currently containerized */ -static int lxcContainerDropCapabilities(void) +static int lxcContainerDropCapabilities(bool dropreboot) { #if HAVE_CAPNG int ret; @@ -1226,11 +1227,11 @@ static int lxcContainerDropCapabilities(void) if ((ret = capng_updatev(CAPNG_DROP, CAPNG_EFFECTIVE | CAPNG_PERMITTED | CAPNG_INHERITABLE | CAPNG_BOUNDING_SET, - CAP_SYS_BOOT, /* No use of reboot */ CAP_SYS_MODULE, /* No kernel module loading */ CAP_SYS_TIME, /* No changing the clock */ CAP_AUDIT_CONTROL, /* No messing with auditing status */ CAP_MAC_ADMIN, /* No messing with LSM config */ + dropreboot ? CAP_SYS_BOOT : -1, /* No use of reboot? */ -1 /* sentinal */)) 0) { lxcError(VIR_ERR_INTERNAL_ERROR, _(Failed to remove capabilities: %d), ret); @@ -1343,7 +1344,7 @@ static int lxcContainerChild( void *data ) } /* drop a set of root capabilities */ -if (lxcContainerDropCapabilities() 0) +if (lxcContainerDropCapabilities(argv-dropreboot) 0) goto cleanup; if (lxcContainerSendContinue(argv-handshakefd) 0) { @@ -1416,6 +1417,7 @@ const char *lxcContainerGetAlt32bitArch(const char *arch) * @veths: interface names * @control: control FD to the container * @ttyPath: path of tty to set as the container console + * @dropreboot: do we need to drop CAP_SYS_BOOT * * Starts a container process by calling clone() with the namespace flags * @@ -1428,7 +1430,8 @@ int lxcContainerStart(virDomainDefPtr def, int control, int handshakefd, char **ttyPaths, - size_t nttyPaths) + size_t nttyPaths, + bool dropreboot) { pid_t pid; int cflags; @@ -1436,7 +1439,7 @@ int lxcContainerStart(virDomainDefPtr def, char *stack, *stacktop; lxc_child_argv_t args = { def, securityDriver, nveths, veths, control, - ttyPaths, nttyPaths, handshakefd}; + ttyPaths, nttyPaths, handshakefd, dropreboot}; /* allocate a stack for the container */ if (VIR_ALLOC_N(stack, stacksize) 0) { diff --git a/src/lxc/lxc_container.h b/src/lxc/lxc_container.h index 77fb9b2..15738c8 100644 --- a/src/lxc/lxc_container.h +++ b/src/lxc/lxc_container.h @@
[libvirt] [PATCH 1/1] Clarify what documentation is being referenced
virsh.pod had several instances in which it referred to the documentation which was a little puzzling to me since it is documentation. Reading the document from end to end makes it clear that it means a specific URI which was noted previously in the text, but I had never noticed those URI in several years of referring to the man page. This patch adds those URIs to several additional places in the text. --- tools/virsh.pod | 38 ++ 1 files changed, 22 insertions(+), 16 deletions(-) diff --git a/tools/virsh.pod b/tools/virsh.pod index cb0d9b9..6040d40 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -73,7 +73,7 @@ instead of the default connection. Enable debug messages at integer ILEVEL and above. ILEVEL can range from 0 to 4 (default). See the documentation of BVIRSH_DEBUG -environment variable for the description of each ILEVEL. +environment variable below for the description of each ILEVEL. =item B-l, B--log IFILE @@ -224,7 +224,8 @@ connect to a local linux container =back -For remote access see the documentation page on how to make URIs. +For remote access see the documentation page at +Lhttp://libvirt.org/uri.html list on how to make URIs. The I--readonly option allows for read-only connection =item Buri @@ -1433,12 +1434,14 @@ format of the device sections to get the most accurate set of accepted values. =item Battach-device Idomain-id IFILE -Attach a device to the domain, using a device definition in an XML file. -See the documentation to learn about libvirt XML format for a device. -For cdrom and floppy devices, this command only replaces the media within -the single existing device; consider using Bupdate-device for this usage. -For passthrough host devices, see also Bnodedev-dettach, needed if -the device does not use managed mode. +Attach a device to the domain, using a device definition in an XML +file. See the documentation at +Lhttp://libvirt.org/formatdomain.html to learn about libvirt XML +format for a device. For cdrom and floppy devices, this command only +replaces the media within the single existing device; consider using +Bupdate-device for this usage. For passthrough host devices, see +also Bnodedev-dettach, needed if the device does not use managed +mode. =item Battach-disk Idomain-id Isource Itarget [I--driver driver] [I--subdriver subdriver] [I--cache cache] @@ -1508,12 +1511,14 @@ if more than one are present on the domain. =item Bupdate-device Idomain-id Ifile [I--persistent] [I--force] -Update the characteristics of a device associated with Idomain-id, based on -the device definition in an XML Ifile. If the I--persistent option is -used, the changes will affect the next boot of the domain. The I--force -option can be used to force device update, e.g., to eject a CD-ROM even if it -is locked/mounted in the domain. See the documentation to learn about libvirt -XML format for a device. +Update the characteristics of a device associated with Idomain-id, +based on the device definition in an XML Ifile. If the +I--persistent option is used, the changes will affect the next boot +of the domain. The I--force option can be used to force device +update, e.g., to eject a CD-ROM even if it is locked/mounted in the +domain. See the documentation at +Lhttp://libvirt.org/formatdomain.html to learn about libvirt XML +format for a device. =back @@ -1617,8 +1622,9 @@ The I--disable option disable autostarting. =item Bnet-create Ifile -Create a virtual network from an XML Ifile, see the documentation to get -a description of the XML network format used by libvirt. +Create a virtual network from an XML Ifile, see the documentation at +Lhttp://libvirt.org/formatnetwork.html to get a description of the +XML network format used by libvirt. =item Bnet-define Ifile -- 1.7.7.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] qemu: unescape HMP commands before converting them to json
On 02/25/2012 05:48 PM, Josh Durgin wrote: QMP commands don't need to be escaped since converting them to json also escapes special characters. When a QMP command fails, however, libvirt falls back to HMP commands. These fallback functions (qemuMonitorText*) do their own escaping, and pass the result directly to qemuMonitorHMPCommandWithFd. If the monitor is in json mode, these pre-escaped commands will be escaped again when converted to json, which can result in the wrong arguments being sent. For example, a filename test\file would be sent in json as test\\file. This prevented attaching an image file with a or \ in its name in qemu 1.0.50, and also broke rbd attachment (which uses backslashes to escape some internal arguments.) Reported-by: Masuko Tomoya tomoya.mas...@gmail.com Signed-off-by: Josh Durgin josh.dur...@dreamhost.com --- Changes since v1: * fix leak of json_cmd * change comments to /* */ instead of // .gitignore |1 + src/qemu/qemu_monitor.c | 67 ++-- src/qemu/qemu_monitor.h |1 + tests/Makefile.am | 12 - tests/qemumonitortest.c | 114 +++ 5 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 tests/qemumonitortest.c diff --git a/.gitignore b/.gitignore index b7561dc..264a419 100644 --- a/.gitignore +++ b/.gitignore @@ -128,6 +128,7 @@ /tests/openvzutilstest /tests/qemuargv2xmltest /tests/qemuhelptest +/tests/qemumonitortest Nice - adding a new test alongside a bug fix is always appreciated. +++ b/tests/qemumonitortest.c @@ -0,0 +1,114 @@ +#include config.h Adding new files without copyright is bad practice. But you are copying existing practice in that directory; which means I'm assuming that you are okay if we later make a global pass on that directory and add a header on all files that need one, whether that header is LGPLv2+ (like most of the rest of the project), GPLv3+ (since tests aren't installed programs), or anything else. I'll go ahead and commit this as is, but please speak up if my assumptions about globally adding an appropriate copyright header to all tests in the future would give you grief. +struct testEscapeString +{ +const char* unescaped; +const char* escaped; Associate the * with the variable, not the type. +static int testEscapeArg(const void *data ATTRIBUTE_UNUSED) +{ +int i; +char *escaped = NULL; +for (i = 0; i ARRAY_CARDINALITY(escapeStrings); ++i) { +escaped = qemuMonitorEscapeArg(escapeStrings[i].unescaped); +if (!escaped) { +if (virTestGetDebug() 0) { +fprintf(stderr, \nUnescaped string [%s]\n, escapeStrings[i].unescaped); +fprintf(stderr, Expect result [%s]\n, escapeStrings[i].escaped); Long lines. +fprintf(stderr, Actual result [%s]\n, escaped); Missing the NULLSTR() wrapper around escaped. Or, since we _know_ escaped is NULL, we can inline the effects of the NULLSTR() wrapper in the first place. +static int testUnescapeArg(const void *data ATTRIBUTE_UNUSED) +{ +int i; +char *unescaped = NULL; +for (i = 0; i ARRAY_CARDINALITY(escapeStrings); ++i) { +unescaped = qemuMonitorUnescapeArg(escapeStrings[i].escaped); +if (!unescaped) { +if (virTestGetDebug() 0) { +fprintf(stderr, \nEscaped string [%s]\n, escapeStrings[i].escaped); +fprintf(stderr, Expect result [%s]\n, escapeStrings[i].unescaped); +fprintf(stderr, Actual result [%s]\n, unescaped); Same problems in reverse :) +static int +mymain(void) +{ +int result = 0; + +#define DO_TEST(_name) \ If you install 'cppi', then 'make syntax-check' complains about this line. ACK with the nits fixed, so I squashed this and pushed. diff --git i/tests/qemumonitortest.c w/tests/qemumonitortest.c index bf90502..cf460ad 100644 --- i/tests/qemumonitortest.c +++ w/tests/qemumonitortest.c @@ -15,8 +15,8 @@ struct testEscapeString { -const char* unescaped; -const char* escaped; +const char *unescaped; +const char *escaped; }; static struct testEscapeString escapeStrings[] = { @@ -40,9 +40,11 @@ static int testEscapeArg(const void *data ATTRIBUTE_UNUSED) escaped = qemuMonitorEscapeArg(escapeStrings[i].unescaped); if (!escaped) { if (virTestGetDebug() 0) { -fprintf(stderr, \nUnescaped string [%s]\n, escapeStrings[i].unescaped); -fprintf(stderr, Expect result [%s]\n, escapeStrings[i].escaped); -fprintf(stderr, Actual result [%s]\n, escaped); +fprintf(stderr, \nUnescaped string [%s]\n, +escapeStrings[i].unescaped); +fprintf(stderr, Expect result [%s]\n, +escapeStrings[i].escaped); +
Re: [libvirt] [PATCH 0/7 v2] virtio-scsi: New device address logic for SCSI devices
On 2012年02月28日 01:14, Eric Blake wrote: On 02/27/2012 04:58 AM, Osier Yang wrote: This patch series completed the support for the first 3 parts of Paolo's proposal: http://permalink.gmane.org/gmane.comp.emulators.libvirt/50428 The 3 parts are: * SCSI controller models * Stable addressing for SCSI devices * LUN passthrough: block devices [PATCH 1/10] and [PATCH 2/10] add two new scsi controllers, ibmvscsi and virtio-scsi. You talk about 1/10, but this mail is only 0/7. Am I missing three patches? Ah, sorry, yeah, it should be 1/7 and 2/7. Patches are merged in this series. Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/7] qemu: Build command line for the new address format
On 2012年02月28日 01:02, Paolo Bonzini wrote: On 02/27/2012 12:59 PM, Osier Yang wrote: +_(target must be 0 for leagacy controller + model 'lsilogic')); Remove (misspelled :)) leagacy. +goto error; +} + +virBufferAddLit(opt, scsi-disk); +virBufferAsprintf(opt, ,bus=scsi%d.%d,scsi-id=%d, + disk-info.addr.drive.controller, + disk-info.addr.drive.bus, + disk-info.addr.drive.unit); +} else { +if (!qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_CHANNEL)) { +if (disk-info.addr.drive.target 7) { +qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, +_(This QEMU doesn't support target + greater than 7)); +goto error; +} + +if ((disk-info.addr.drive.bus != disk-info.addr.drive.unit) +(disk-info.addr.drive.bus != 0)) { +qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, +_(This QEMU only supports both bus and + unit are equal to 0)); Remove are. +goto error; Otherwise the series looks good. Thanks! Paolo Fixed these nits when pushing. Thanks! Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/7] conf: Introduce new attribute for device address format
On 2012年02月28日 01:30, Eric Blake wrote: On 02/27/2012 04:58 AM, Osier Yang wrote: * src/conf/domain_conf.h: Add new member target to struct _virDomainDeviceDriveAddress. * src/conf/domain_conf.c: Parse and format target * Lots of tests (.xml) in tests/domainsnapshotxml2xmlout, tests/qemuxml2argvdata, tests/qemuxml2xmloutdata, and tests/vmx2xmldata/ are modified for newly introduced attribute target for address of drive type. --- docs/formatdomain.html.in | 12 ++-- docs/schemas/domaincommon.rng | 10 ++ src/conf/domain_conf.c | 17 + src/conf/domain_conf.h |1 + tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 12 ++-- This modifies existing tests, but I didn't (quickly) see any addition of a new test with a non-zero target. tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml |4 ++-- 194 files changed, 292 insertions(+), 264 deletions(-) Evidence of my claim includes the fact that this patch did not add any new files, and none of the tests added more lines than were removed. Yes, it's in 7/7, I wanted to add the .args and .xml files together in one patch. @@ -2016,7 +2017,6 @@ virDomainDeviceInfoFormat(virBufferPtr buf, return 0; } - static int virDomainDevicePCIAddressParseXML(xmlNodePtr node, virDomainDevicePCIAddressPtr addr) Spurious whitespace change, but I can live with it. I'm okay if you add an 8/7 with further tests of the new XML (or, I may be surprised by 5-7/7 adding those tests). -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 7/7] tests: Add tests for virtio-scsi and ibmvscsi controllers
On 2012年02月28日 01:41, Eric Blake wrote: On 02/27/2012 04:59 AM, Osier Yang wrote: --- .../qemuxml2argv-disk-scsi-virtio-scsi.args|9 + .../qemuxml2argv-disk-scsi-virtio-scsi.xml | 32 .../qemuxml2argv-disk-scsi-vscsi.args |8 + .../qemuxml2argv-disk-scsi-vscsi.xml | 32 tests/qemuxml2argvtest.c |4 ++ tests/qemuxml2xmltest.c|4 ++- 6 files changed, 88 insertions(+), 1 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-virtio-scsi.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-vscsi.xml OK, I think this fixes most of my comment on 4/7; but I still don't see any non-zero target='1' entries in the new tests. If you fix Paolo's nits, as well as enhance that aspect of the tests, then you have my: ACK series. Updates these 2 new tests with target != 0 for no lsilogic scsi type controllers. And pushed. Thanks for the reviewing! Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] virsh: Break long lines in virsh.pod
No content changes, just breaking long lines. Pushed under trivial rule. --- tools/virsh.pod | 13 - 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/virsh.pod b/tools/virsh.pod index aa4c560..c306a38 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -468,7 +468,8 @@ Flags I--live or I--config select whether this command works on live or persistent definitions of the domain. If both I--live and I--config are specified, the I--config option takes precedence on getting the current description and both live configuration and config are updated while setting -the description. I--current is exclusive and implied if none of these was specified. +the description. I--current is exclusive and implied if none of these was +specified. Flag I--edit specifies that an editor with the contents of current description or title should be opened and the contents saved back afterwards. @@ -1471,7 +1472,8 @@ address. [I--persistent] [I--inbound average,peak,burst] [I--outbound average,peak,burst] Attach a new network interface to the domain. -Itype can be either Inetwork to indicate a physical network device or Ibridge to indicate a bridge to a device. +Itype can be either Inetwork to indicate a physical network device or +Ibridge to indicate a bridge to a device. Isource indicates the source device. Itarget allows to indicate the target device in the guest. Imac allows to specify the MAC address of the network interface. @@ -1502,9 +1504,10 @@ from the domain. =item Bdetach-interface Idomain-id Itype [I--mac mac] Detach a network interface from a domain. -Itype can be either Inetwork to indicate a physical network device or Ibridge to indicate a bridge to a device. -It is recommended to use the Imac option to distinguish between the interfaces -if more than one are present on the domain. +Itype can be either Inetwork to indicate a physical network device or +Ibridge to indicate a bridge to a device. It is recommended to use the +Imac option to distinguish between the interfaces if more than one are +present on the domain. =item Bupdate-device Idomain-id Ifile [I--persistent] [I--force] -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list