From jferlan at redhat.com Tue Aug 5 23:22:37 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 5 Aug 2014 19:22:37 -0400 Subject: [Libvirt-cim] [PATCH v4 2/3] hostdev: Add iSCSI hostdev XML In-Reply-To: <1407269369-27437-3-git-send-email-jferlan@redhat.com> References: <1407269369-27437-3-git-send-email-jferlan@redhat.com> Message-ID: <1407280957-25431-1-git-send-email-jferlan@redhat.com> Introduce a new structure to handle an iSCSI host device based on the existing virDomainHostdevSubsysSCSI by adding a "protocol='iscsi'" to the element. The hostdev structure mimics the existing element for an iSCSI device (network) device. New XML is:
The controller element will mimic the existing scsi_host code insomuch as when 'lsi' and 'virtio-scsi' are used. Signed-off-by: John Ferlan --- Changes since v3: * Rework RNG to match comments from review 8/8 * Move the inside the * Modify the tests and html doc to match where the is found docs/formatdomain.html.in | 144 +++++++++++++------- docs/schemas/domaincommon.rng | 51 ++++++- src/conf/domain_conf.c | 150 ++++++++++++++++++--- .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args | 14 ++ .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml | 46 +++++++ .../qemuxml2argv-hostdev-scsi-lsi-iscsi.args | 14 ++ .../qemuxml2argv-hostdev-scsi-lsi-iscsi.xml | 40 ++++++ ...emuxml2argv-hostdev-scsi-virtio-iscsi-auth.args | 16 +++ ...qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml | 46 +++++++ .../qemuxml2argv-hostdev-scsi-virtio-iscsi.args | 16 +++ .../qemuxml2argv-hostdev-scsi-virtio-iscsi.xml | 40 ++++++ tests/qemuxml2argvtest.c | 16 +++ tests/qemuxml2xmltest.c | 5 + 13 files changed, 529 insertions(+), 69 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index e5b1adb..8b294bd 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2824,57 +2824,107 @@ </devices> ... + +

or:

+ +
+  ...
+  <devices>
+    <hostdev mode='subsystem' type='scsi'>
+      <source protocol='iscsi' name='iqn.2014-08.com.example:iscsi-nopool/1'>
+        <host name='example.com' port='3260'/>
+        <auth username='myuser'>
+          <secret type='iscsi' usage='libvirtiscsi'/>
+        </auth>
+      </source>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </hostdev>
+  </devices>
+  ...
+
hostdev
The hostdev element is the main container for describing - host devices. For usb device passthrough mode is always - "subsystem" and type is "usb" for a USB device, "pci" - for a PCI device and "scsi" for a SCSI device. When - managed is "yes" for a PCI - device, it is detached from the host before being passed on to - the guest, and reattached to the host after the guest exits. - If managed is omitted or "no", and for USB - devices, the user is responsible to - call virNodeDeviceDettach (or virsh - nodedev-dettach) before starting the guest or - hot-plugging the device, - and virNodeDeviceReAttach (or virsh - nodedev-reattach) after hot-unplug or stopping the - guest. For SCSI device, user is responsible to make sure the device - is not used by host. - The optional sgio (since 1.0.6) - attribute indicates whether the kernel will filter unprivileged - SG_IO commands for the disk, valid settings are "filtered" or - "unfiltered". Defaults to "filtered". + host devices. For each device, the mode is always + "subsystem" and the type is one of the following values + with additional attributes noted. +
+
usb
+
For USB devices, the user is responsible to call + virNodeDeviceDettach (or + virsh nodedev-detach) before starting the guest + or hot-plugging the device and virNodeDeviceReAttach + (or virsh nodedev-reattach) after hot-unplug or + stopping the guest. +
+
pci
+
For PCI devices, when managed is "yes" it is + detached from the host before being passed on to the guest + and reattached to the host after the guest exits. If + managed is omitted or "no", follow the steps + described for a USB device to detach before starting the + guest or hot-plugging and reattach after stopping the guest + or hot-unplug. +
+
scsi
+
For SCSI devices, user is responsible to make sure the device + is not used by host. The optional sgio + (since 1.0.6) attribute indicates + whether the kernel will filter unprivileged SG_IO commands for + the disk, valid settings are "filtered" or "unfiltered". + The default is "filtered". +
+
source
-
The source element describes the device as seen from the host. - The USB device can either be addressed by vendor / product id using the - vendor and product elements or by the device's - address on the hosts using the address element. PCI devices - on the other hand can only be described by their address. - SCSI devices are described by both the adapter and - address elements. - - Since 1.0.0, the source element - of USB devices may contain startupPolicy attribute which can - be used to define policy what to do if the specified host USB device is - not found. The attribute accepts the following values: - - - - - - - - - - - - - -
mandatory fail if missing for any reason (the default)
requisite fail if missing on boot up, - drop if missing on migrate/restore/revert
optional drop if missing at any start attempt
+
The source element describes the device as seen from the host using + the following mechanism to describe: +
+
usb
+
The USB device can either be addressed by vendor / product id + using the vendor and product elements + or by the device's address on the host using the + address element. +

+ Since 1.0.0, the source + element of USB devices may contain startupPolicy + attribute which can be used to define policy what to do if the + specified host USB device is not found. The attribute accepts + the following values: +

+ + + + + + + + + + + + + +
mandatory fail if missing for any reason (the default)
requisite fail if missing on boot up, + drop if missing on migrate/restore/revert
optional drop if missing at any start attempt
+
+
pci
+
PCI devices can only be described by their address. +
+
scsi
+
SCSI devices are described by both the adapter + and address elements. +

+ Since 1.2.8, the source + element of a SCSI device may contain the protocol + attribute. When the attribute is set to "iscsi", the host + device XML follows the network disk + device using the same name attribute and optionally + using the auth element to provide the authentication + credentials to the iSCSI server. +

+
+
vendor, product
The vendor and product elements each have an @@ -3589,7 +3639,7 @@ before being passed on to the guest, and reattached to the host after the guest exits. If managed is omitted or "no", the user is responsible to call virNodeDeviceDettach - (or virsh nodedev-dettach) before starting the guest + (or virsh nodedev-detach) before starting the guest or hot-plugging the device, and virNodeDeviceReAttach (or virsh nodedev-reattach) after hot-unplug or stopping the guest. diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 11f0fd0..b7a1b6f 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3589,12 +3589,51 @@ - - - - - - + + + + + + adapter + + + + + + + + + + + + + + iscsi + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 358afae..d87ca24 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -597,6 +597,11 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysPCIBackend, "vfio", "xen") +VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIProtocol, + VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST, + "adapter", + "iscsi") + VIR_ENUM_IMPL(virDomainHostdevCaps, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST, "storage", "misc", @@ -4213,10 +4218,96 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode, } static int +virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode, + virDomainHostdevSubsysSCSIPtr def) +{ + int ret = -1; + int auth_secret_usage = -1; + xmlNodePtr cur; + virStorageAuthDefPtr authdef = NULL; + virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &def->u.iscsi; + + /* Similar to virDomainDiskSourceParse for a VIR_STORAGE_TYPE_NETWORK */ + + if (!(iscsisrc->path = virXMLPropString(sourcenode, "name"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing iSCSI hostdev source path name")); + goto cleanup; + } + + if (virDomainStorageHostParse(sourcenode, &iscsisrc->hosts, + &iscsisrc->nhosts) < 0) + goto cleanup; + + if (iscsisrc->nhosts < 1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing the host address for the iSCSI hostdev")); + goto cleanup; + } + if (iscsisrc->nhosts > 1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("only one source host address may be specified " + "for the iSCSI hostdev")); + goto cleanup; + } + + cur = sourcenode->children; + while (cur != NULL) { + if (cur->type == XML_ELEMENT_NODE && + xmlStrEqual(cur->name, BAD_CAST "auth")) { + if (!(authdef = virStorageAuthDefParse(sourcenode->doc, cur))) + goto cleanup; + if ((auth_secret_usage = + virSecretUsageTypeFromString(authdef->secrettype)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("invalid secret type %s"), + authdef->secrettype); + goto cleanup; + } + if (auth_secret_usage != VIR_SECRET_USAGE_TYPE_ISCSI) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("hostdev invalid secret type '%s'"), + authdef->secrettype); + goto cleanup; + } + iscsisrc->auth = authdef; + authdef = NULL; + } + cur = cur->next; + } + ret = 0; + + cleanup: + virStorageAuthDefFree(authdef); + return ret; +} + +static int virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode, virDomainHostdevSubsysSCSIPtr scsisrc) { - return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc); + char *protocol = NULL; + int ret = -1; + + if ((protocol = virXMLPropString(sourcenode, "protocol"))) { + scsisrc->protocol = + virDomainHostdevSubsysSCSIProtocolTypeFromString(protocol); + if (scsisrc->protocol < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown SCSI subsystem protocol '%s'"), + protocol); + goto cleanup; + } + } + + if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) + ret = virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsisrc); + else + ret = virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc); + + cleanup: + VIR_FREE(protocol); + return ret; } /* Check if a drive type address $controller:0:0:$unit is already @@ -15761,6 +15852,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, virDomainHostdevSubsysPCIPtr pcisrc = &def->source.subsys.u.pci; virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi; virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host; + virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi; if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI && pcisrc->backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) { @@ -15777,17 +15869,27 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, } virBufferAddLit(buf, "startupPolicy) { - const char *policy; - policy = virDomainStartupPolicyTypeToString(def->startupPolicy); - virBufferAsprintf(buf, " startupPolicy='%s'", policy); + if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { + if (def->startupPolicy) { + const char *policy; + policy = virDomainStartupPolicyTypeToString(def->startupPolicy); + virBufferAsprintf(buf, " startupPolicy='%s'", policy); + } + if (usbsrc->autoAddress && (flags & VIR_DOMAIN_XML_MIGRATABLE)) + virBufferAddLit(buf, " autoAddress='yes'"); + + if (def->missing && !(flags & VIR_DOMAIN_XML_INACTIVE)) + virBufferAddLit(buf, " missing='yes'"); } - if (usbsrc->autoAddress && (flags & VIR_DOMAIN_XML_MIGRATABLE)) - virBufferAddLit(buf, " autoAddress='yes'"); - if (def->missing && - !(flags & VIR_DOMAIN_XML_INACTIVE)) - virBufferAddLit(buf, " missing='yes'"); + if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && + scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { + const char *protocol = + virDomainHostdevSubsysSCSIProtocolTypeToString(scsisrc->protocol); + + virBufferAsprintf(buf, " protocol='%s' name='%s'", + protocol, iscsisrc->path); + } virBufferAddLit(buf, ">\n"); @@ -15828,12 +15930,20 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, } break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: - virBufferAsprintf(buf, "\n", - scsihostsrc->adapter); - virBufferAsprintf(buf, "
\n", - includeTypeInAddr ? "type='scsi' " : "", - scsihostsrc->bus, scsihostsrc->target, - scsihostsrc->unit); + if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { + virBufferAddLit(buf, "hosts[0].name); + virBufferEscapeString(buf, " port='%s'", iscsisrc->hosts[0].port); + virBufferAddLit(buf, "/>\n"); + } else { + virBufferAsprintf(buf, "\n", + scsihostsrc->adapter); + virBufferAsprintf(buf, + "
\n", + includeTypeInAddr ? "type='scsi' " : "", + scsihostsrc->bus, scsihostsrc->target, + scsihostsrc->unit); + } break; default: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -15842,8 +15952,16 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, return -1; } + if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && + scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI && + iscsisrc->auth) { + if (virStorageAuthDefFormat(buf, iscsisrc->auth) < 0) + return -1; + } + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); + return 0; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args new file mode 100644 index 0000000..6638dce --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args @@ -0,0 +1,14 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device lsi,id=scsi0,bus=pci.0,addr=0x3 -usb \ +-drive file=/dev/HostVG/QEMUGuest2,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=iscsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A at example.org\ +:3260/iqn.1992-01.com.example,if=none,format=raw,id=drive-hostdev0 \ +-device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev0,id=hostdev0 \ +-drive file=iscsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A at example.org\ +:3260/iqn.1992-01.com.example/1,if=none,format=raw,id=drive-hostdev1 \ +-device scsi-generic,bus=scsi0.0,scsi-id=5,drive=drive-hostdev1,id=hostdev1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml new file mode 100644 index 0000000..3bfded4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml @@ -0,0 +1,46 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9466-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args new file mode 100644 index 0000000..2aebe9c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args @@ -0,0 +1,14 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device lsi,id=scsi0,bus=pci.0,addr=0x3 -usb \ +-drive file=/dev/HostVG/QEMUGuest2,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=iscsi://example.org:3260/iqn.1992-01.com.example,if=none,\ +format=raw,id=drive-hostdev0 \ +-device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev0,id=hostdev0 \ +-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/1,if=none,\ +format=raw,id=drive-hostdev1 \ +-device scsi-generic,bus=scsi0.0,scsi-id=5,drive=drive-hostdev1,id=hostdev1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml new file mode 100644 index 0000000..8a05099 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml @@ -0,0 +1,40 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9466-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + + + +
+ + + + + +
+ + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args new file mode 100644 index 0000000..7fd3a00 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args @@ -0,0 +1,16 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb \ +-drive file=/dev/HostVG/QEMUGuest2,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=iscsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A at example.org\ +:3260/iqn.1992-01.com.example,if=none,format=raw,id=drive-hostdev0 \ +-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=4,\ +drive=drive-hostdev0,id=hostdev0 \ +-drive file=iscsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A at example.org\ +:3260/iqn.1992-01.com.example/1,if=none,format=raw,id=drive-hostdev1 \ +-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=5,\ +drive=drive-hostdev1,id=hostdev1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml new file mode 100644 index 0000000..d4dba4a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml @@ -0,0 +1,46 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9466-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ + + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args new file mode 100644 index 0000000..e4b6e97 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args @@ -0,0 +1,16 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefaults -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb \ +-drive file=/dev/HostVG/QEMUGuest2,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=iscsi://example.org:3260/iqn.1992-01.com.example,if=none,\ +format=raw,id=drive-hostdev0 \ +-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=4,\ +drive=drive-hostdev0,id=hostdev0 \ +-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/1,if=none,\ +format=raw,id=drive-hostdev1 \ +-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=5,\ +drive=drive-hostdev1,id=hostdev1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml new file mode 100644 index 0000000..13c0930 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml @@ -0,0 +1,40 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9466-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + +
+ + + + + + + + + +
+ + + + + +
+ + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 12ecabc..609c1bc 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1353,6 +1353,22 @@ mymain(void) QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_SCSI_GENERIC, QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX); + DO_TEST("hostdev-scsi-lsi-iscsi", QEMU_CAPS_DRIVE, + QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, + QEMU_CAPS_DEVICE_SCSI_GENERIC); + DO_TEST("hostdev-scsi-lsi-iscsi-auth", QEMU_CAPS_DRIVE, + QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, + QEMU_CAPS_DEVICE_SCSI_GENERIC); + DO_TEST("hostdev-scsi-virtio-iscsi", QEMU_CAPS_DRIVE, + QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_DEVICE_SCSI_GENERIC); + DO_TEST("hostdev-scsi-virtio-iscsi-auth", QEMU_CAPS_DRIVE, + QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI, + QEMU_CAPS_DEVICE_SCSI_GENERIC); DO_TEST("mlock-on", QEMU_CAPS_MLOCK); DO_TEST_FAILURE("mlock-on", NONE); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 451dedc..7d416d0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -361,6 +361,11 @@ mymain(void) DO_TEST_DIFFERENT("hostdev-scsi-autogen-address"); + DO_TEST("hostdev-scsi-lsi-iscsi"); + DO_TEST("hostdev-scsi-lsi-iscsi-auth"); + DO_TEST("hostdev-scsi-virtio-iscsi"); + DO_TEST("hostdev-scsi-virtio-iscsi-auth"); + DO_TEST_DIFFERENT("s390-defaultconsole"); DO_TEST("pcihole64"); -- 1.9.3 From jferlan at redhat.com Tue Aug 5 23:24:20 2014 From: jferlan at redhat.com (John Ferlan) Date: Tue, 05 Aug 2014 19:24:20 -0400 Subject: [Libvirt-cim] [PATCH v4 2/3] hostdev: Add iSCSI hostdev XML In-Reply-To: <1407280957-25431-1-git-send-email-jferlan@redhat.com> References: <1407269369-27437-3-git-send-email-jferlan@redhat.com> <1407280957-25431-1-git-send-email-jferlan@redhat.com> Message-ID: <53E167A4.6060908@redhat.com> Wow *that*'s not what I was trying to - ignore... John On 08/05/2014 07:22 PM, John Ferlan wrote: > Introduce a new structure to handle an iSCSI host device based on the > existing virDomainHostdevSubsysSCSI by adding a "protocol='iscsi'" to > the element. The hostdev structure mimics the existing > element for an iSCSI device (network) device. New XML is: > > > > > > > > >
> > > The controller element will mimic the existing scsi_host code insomuch > as when 'lsi' and 'virtio-scsi' are used. > > Signed-off-by: John Ferlan > --- > Changes since v3: > * Rework RNG to match comments from review 8/8 > * Move the inside the > * Modify the tests and html doc to match where the is found > > docs/formatdomain.html.in | 144 +++++++++++++------- > docs/schemas/domaincommon.rng | 51 ++++++- > src/conf/domain_conf.c | 150 ++++++++++++++++++--- > .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args | 14 ++ > .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml | 46 +++++++ > .../qemuxml2argv-hostdev-scsi-lsi-iscsi.args | 14 ++ > .../qemuxml2argv-hostdev-scsi-lsi-iscsi.xml | 40 ++++++ > ...emuxml2argv-hostdev-scsi-virtio-iscsi-auth.args | 16 +++ > ...qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml | 46 +++++++ > .../qemuxml2argv-hostdev-scsi-virtio-iscsi.args | 16 +++ > .../qemuxml2argv-hostdev-scsi-virtio-iscsi.xml | 40 ++++++ > tests/qemuxml2argvtest.c | 16 +++ > tests/qemuxml2xmltest.c | 5 + > 13 files changed, 529 insertions(+), 69 deletions(-) > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml > > diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in > index e5b1adb..8b294bd 100644 > --- a/docs/formatdomain.html.in > +++ b/docs/formatdomain.html.in > @@ -2824,57 +2824,107 @@ > </devices> > ... > > + > +

or:

> + > +
> +  ...
> +  <devices>
> +    <hostdev mode='subsystem' type='scsi'>
> +      <source protocol='iscsi' name='iqn.2014-08.com.example:iscsi-nopool/1'>
> +        <host name='example.com' port='3260'/>
> +        <auth username='myuser'>
> +          <secret type='iscsi' usage='libvirtiscsi'/>
> +        </auth>
> +      </source>
> +      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
> +    </hostdev>
> +  </devices>
> +  ...
> + >
>
hostdev
>
The hostdev element is the main container for describing > - host devices. For usb device passthrough mode is always > - "subsystem" and type is "usb" for a USB device, "pci" > - for a PCI device and "scsi" for a SCSI device. When > - managed is "yes" for a PCI > - device, it is detached from the host before being passed on to > - the guest, and reattached to the host after the guest exits. > - If managed is omitted or "no", and for USB > - devices, the user is responsible to > - call virNodeDeviceDettach (or virsh > - nodedev-dettach) before starting the guest or > - hot-plugging the device, > - and virNodeDeviceReAttach (or virsh > - nodedev-reattach) after hot-unplug or stopping the > - guest. For SCSI device, user is responsible to make sure the device > - is not used by host. > - The optional sgio (since 1.0.6) > - attribute indicates whether the kernel will filter unprivileged > - SG_IO commands for the disk, valid settings are "filtered" or > - "unfiltered". Defaults to "filtered". > + host devices. For each device, the mode is always > + "subsystem" and the type is one of the following values > + with additional attributes noted. > +
> +
usb
> +
For USB devices, the user is responsible to call > + virNodeDeviceDettach (or > + virsh nodedev-detach) before starting the guest > + or hot-plugging the device and virNodeDeviceReAttach > + (or virsh nodedev-reattach) after hot-unplug or > + stopping the guest. > +
> +
pci
> +
For PCI devices, when managed is "yes" it is > + detached from the host before being passed on to the guest > + and reattached to the host after the guest exits. If > + managed is omitted or "no", follow the steps > + described for a USB device to detach before starting the > + guest or hot-plugging and reattach after stopping the guest > + or hot-unplug. > +
> +
scsi
> +
For SCSI devices, user is responsible to make sure the device > + is not used by host. The optional sgio > + (since 1.0.6) attribute indicates > + whether the kernel will filter unprivileged SG_IO commands for > + the disk, valid settings are "filtered" or "unfiltered". > + The default is "filtered". > +
> +
>
>
source
> -
The source element describes the device as seen from the host. > - The USB device can either be addressed by vendor / product id using the > - vendor and product elements or by the device's > - address on the hosts using the address element. PCI devices > - on the other hand can only be described by their address. > - SCSI devices are described by both the adapter and > - address elements. > - > - Since 1.0.0, the source element > - of USB devices may contain startupPolicy attribute which can > - be used to define policy what to do if the specified host USB device is > - not found. The attribute accepts the following values: > - > - > - > - > - > - > - > - > - > - > - > - > - > -
mandatory fail if missing for any reason (the default)
requisite fail if missing on boot up, > - drop if missing on migrate/restore/revert
optional drop if missing at any start attempt
> +
The source element describes the device as seen from the host using > + the following mechanism to describe: > +
> +
usb
> +
The USB device can either be addressed by vendor / product id > + using the vendor and product elements > + or by the device's address on the host using the > + address element. > +

> + Since 1.0.0, the source > + element of USB devices may contain startupPolicy > + attribute which can be used to define policy what to do if the > + specified host USB device is not found. The attribute accepts > + the following values: > +

> + > + > + > + > + > + > + > + > + > + > + > + > + > +
mandatory fail if missing for any reason (the default)
requisite fail if missing on boot up, > + drop if missing on migrate/restore/revert
optional drop if missing at any start attempt
> +
> +
pci
> +
PCI devices can only be described by their address. > +
> +
scsi
> +
SCSI devices are described by both the adapter > + and address elements. > +

> + Since 1.2.8, the source > + element of a SCSI device may contain the protocol > + attribute. When the attribute is set to "iscsi", the host > + device XML follows the network disk > + device using the same name attribute and optionally > + using the auth element to provide the authentication > + credentials to the iSCSI server. > +

> +
> +
>
>
vendor, product
>
The vendor and product elements each have an > @@ -3589,7 +3639,7 @@ > before being passed on to the guest, and reattached to the host > after the guest exits. If managed is omitted or "no", > the user is responsible to call virNodeDeviceDettach > - (or virsh nodedev-dettach) before starting the guest > + (or virsh nodedev-detach) before starting the guest > or hot-plugging the device, and virNodeDeviceReAttach > (or virsh nodedev-reattach) after hot-unplug or > stopping the guest. > diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng > index 11f0fd0..b7a1b6f 100644 > --- a/docs/schemas/domaincommon.rng > +++ b/docs/schemas/domaincommon.rng > @@ -3589,12 +3589,51 @@ > > > > - > - > - > - > - > - > + > + > + > + > + > + adapter > + > + > + > + > + > + > + > + > + > + > + > + > + > + iscsi > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > > > > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index 358afae..d87ca24 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -597,6 +597,11 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysPCIBackend, > "vfio", > "xen") > > +VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIProtocol, > + VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST, > + "adapter", > + "iscsi") > + > VIR_ENUM_IMPL(virDomainHostdevCaps, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST, > "storage", > "misc", > @@ -4213,10 +4218,96 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode, > } > > static int > +virDomainHostdevSubsysSCSIiSCSIDefParseXML(xmlNodePtr sourcenode, > + virDomainHostdevSubsysSCSIPtr def) > +{ > + int ret = -1; > + int auth_secret_usage = -1; > + xmlNodePtr cur; > + virStorageAuthDefPtr authdef = NULL; > + virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &def->u.iscsi; > + > + /* Similar to virDomainDiskSourceParse for a VIR_STORAGE_TYPE_NETWORK */ > + > + if (!(iscsisrc->path = virXMLPropString(sourcenode, "name"))) { > + virReportError(VIR_ERR_XML_ERROR, "%s", > + _("missing iSCSI hostdev source path name")); > + goto cleanup; > + } > + > + if (virDomainStorageHostParse(sourcenode, &iscsisrc->hosts, > + &iscsisrc->nhosts) < 0) > + goto cleanup; > + > + if (iscsisrc->nhosts < 1) { > + virReportError(VIR_ERR_XML_ERROR, "%s", > + _("missing the host address for the iSCSI hostdev")); > + goto cleanup; > + } > + if (iscsisrc->nhosts > 1) { > + virReportError(VIR_ERR_XML_ERROR, "%s", > + _("only one source host address may be specified " > + "for the iSCSI hostdev")); > + goto cleanup; > + } > + > + cur = sourcenode->children; > + while (cur != NULL) { > + if (cur->type == XML_ELEMENT_NODE && > + xmlStrEqual(cur->name, BAD_CAST "auth")) { > + if (!(authdef = virStorageAuthDefParse(sourcenode->doc, cur))) > + goto cleanup; > + if ((auth_secret_usage = > + virSecretUsageTypeFromString(authdef->secrettype)) < 0) { > + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, > + _("invalid secret type %s"), > + authdef->secrettype); > + goto cleanup; > + } > + if (auth_secret_usage != VIR_SECRET_USAGE_TYPE_ISCSI) { > + virReportError(VIR_ERR_INTERNAL_ERROR, > + _("hostdev invalid secret type '%s'"), > + authdef->secrettype); > + goto cleanup; > + } > + iscsisrc->auth = authdef; > + authdef = NULL; > + } > + cur = cur->next; > + } > + ret = 0; > + > + cleanup: > + virStorageAuthDefFree(authdef); > + return ret; > +} > + > +static int > virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode, > virDomainHostdevSubsysSCSIPtr scsisrc) > { > - return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc); > + char *protocol = NULL; > + int ret = -1; > + > + if ((protocol = virXMLPropString(sourcenode, "protocol"))) { > + scsisrc->protocol = > + virDomainHostdevSubsysSCSIProtocolTypeFromString(protocol); > + if (scsisrc->protocol < 0) { > + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, > + _("Unknown SCSI subsystem protocol '%s'"), > + protocol); > + goto cleanup; > + } > + } > + > + if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) > + ret = virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, scsisrc); > + else > + ret = virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc); > + > + cleanup: > + VIR_FREE(protocol); > + return ret; > } > > /* Check if a drive type address $controller:0:0:$unit is already > @@ -15761,6 +15852,7 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, > virDomainHostdevSubsysPCIPtr pcisrc = &def->source.subsys.u.pci; > virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi; > virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host; > + virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi; > > if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI && > pcisrc->backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) { > @@ -15777,17 +15869,27 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, > } > > virBufferAddLit(buf, " - if (def->startupPolicy) { > - const char *policy; > - policy = virDomainStartupPolicyTypeToString(def->startupPolicy); > - virBufferAsprintf(buf, " startupPolicy='%s'", policy); > + if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { > + if (def->startupPolicy) { > + const char *policy; > + policy = virDomainStartupPolicyTypeToString(def->startupPolicy); > + virBufferAsprintf(buf, " startupPolicy='%s'", policy); > + } > + if (usbsrc->autoAddress && (flags & VIR_DOMAIN_XML_MIGRATABLE)) > + virBufferAddLit(buf, " autoAddress='yes'"); > + > + if (def->missing && !(flags & VIR_DOMAIN_XML_INACTIVE)) > + virBufferAddLit(buf, " missing='yes'"); > } > - if (usbsrc->autoAddress && (flags & VIR_DOMAIN_XML_MIGRATABLE)) > - virBufferAddLit(buf, " autoAddress='yes'"); > > - if (def->missing && > - !(flags & VIR_DOMAIN_XML_INACTIVE)) > - virBufferAddLit(buf, " missing='yes'"); > + if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && > + scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { > + const char *protocol = > + virDomainHostdevSubsysSCSIProtocolTypeToString(scsisrc->protocol); > + > + virBufferAsprintf(buf, " protocol='%s' name='%s'", > + protocol, iscsisrc->path); > + } > > virBufferAddLit(buf, ">\n"); > > @@ -15828,12 +15930,20 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, > } > break; > case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: > - virBufferAsprintf(buf, "\n", > - scsihostsrc->adapter); > - virBufferAsprintf(buf, "
\n", > - includeTypeInAddr ? "type='scsi' " : "", > - scsihostsrc->bus, scsihostsrc->target, > - scsihostsrc->unit); > + if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) { > + virBufferAddLit(buf, " + virBufferEscapeString(buf, " name='%s'", iscsisrc->hosts[0].name); > + virBufferEscapeString(buf, " port='%s'", iscsisrc->hosts[0].port); > + virBufferAddLit(buf, "/>\n"); > + } else { > + virBufferAsprintf(buf, "\n", > + scsihostsrc->adapter); > + virBufferAsprintf(buf, > + "
\n", > + includeTypeInAddr ? "type='scsi' " : "", > + scsihostsrc->bus, scsihostsrc->target, > + scsihostsrc->unit); > + } > break; > default: > virReportError(VIR_ERR_INTERNAL_ERROR, > @@ -15842,8 +15952,16 @@ virDomainHostdevDefFormatSubsys(virBufferPtr buf, > return -1; > } > > + if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && > + scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI && > + iscsisrc->auth) { > + if (virStorageAuthDefFormat(buf, iscsisrc->auth) < 0) > + return -1; > + } > + > virBufferAdjustIndent(buf, -2); > virBufferAddLit(buf, "\n"); > + > return 0; > } > > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args > new file mode 100644 > index 0000000..6638dce > --- /dev/null > +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args > @@ -0,0 +1,14 @@ > +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ > +/usr/bin/qemu -S -M \ > +pc -m 214 -smp 1 -nographic -nodefaults -monitor \ > +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ > +-device lsi,id=scsi0,bus=pci.0,addr=0x3 -usb \ > +-drive file=/dev/HostVG/QEMUGuest2,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=iscsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A at example.org\ > +:3260/iqn.1992-01.com.example,if=none,format=raw,id=drive-hostdev0 \ > +-device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev0,id=hostdev0 \ > +-drive file=iscsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A at example.org\ > +:3260/iqn.1992-01.com.example/1,if=none,format=raw,id=drive-hostdev1 \ > +-device scsi-generic,bus=scsi0.0,scsi-id=5,drive=drive-hostdev1,id=hostdev1 \ > +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml > new file mode 100644 > index 0000000..3bfded4 > --- /dev/null > +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml > @@ -0,0 +1,46 @@ > + > + QEMUGuest2 > + c7a5fdbd-edaf-9466-926a-d65c16db1809 > + 219100 > + 219100 > + 1 > + > + hvm > + > + > + > + destroy > + restart > + destroy > + > + /usr/bin/qemu > + > + > + > +
> + > + > + > + > + > + > + > + > + > + > + > + > +
> + > + > + > + > + > + > + > + > +
> + > + > + > + > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args > new file mode 100644 > index 0000000..2aebe9c > --- /dev/null > +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args > @@ -0,0 +1,14 @@ > +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ > +/usr/bin/qemu -S -M \ > +pc -m 214 -smp 1 -nographic -nodefaults -monitor \ > +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ > +-device lsi,id=scsi0,bus=pci.0,addr=0x3 -usb \ > +-drive file=/dev/HostVG/QEMUGuest2,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=iscsi://example.org:3260/iqn.1992-01.com.example,if=none,\ > +format=raw,id=drive-hostdev0 \ > +-device scsi-generic,bus=scsi0.0,scsi-id=4,drive=drive-hostdev0,id=hostdev0 \ > +-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/1,if=none,\ > +format=raw,id=drive-hostdev1 \ > +-device scsi-generic,bus=scsi0.0,scsi-id=5,drive=drive-hostdev1,id=hostdev1 \ > +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml > new file mode 100644 > index 0000000..8a05099 > --- /dev/null > +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml > @@ -0,0 +1,40 @@ > + > + QEMUGuest2 > + c7a5fdbd-edaf-9466-926a-d65c16db1809 > + 219100 > + 219100 > + 1 > + > + hvm > + > + > + > + destroy > + restart > + destroy > + > + /usr/bin/qemu > + > + > + > +
> + > + > + > + > + > + > + > + > + > +
> + > + > + > + > + > +
> + > + > + > + > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args > new file mode 100644 > index 0000000..7fd3a00 > --- /dev/null > +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args > @@ -0,0 +1,16 @@ > +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ > +/usr/bin/qemu -S -M \ > +pc -m 214 -smp 1 -nographic -nodefaults -monitor \ > +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ > +-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb \ > +-drive file=/dev/HostVG/QEMUGuest2,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=iscsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A at example.org\ > +:3260/iqn.1992-01.com.example,if=none,format=raw,id=drive-hostdev0 \ > +-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=4,\ > +drive=drive-hostdev0,id=hostdev0 \ > +-drive file=iscsi://myname:AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A at example.org\ > +:3260/iqn.1992-01.com.example/1,if=none,format=raw,id=drive-hostdev1 \ > +-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=5,\ > +drive=drive-hostdev1,id=hostdev1 \ > +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml > new file mode 100644 > index 0000000..d4dba4a > --- /dev/null > +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml > @@ -0,0 +1,46 @@ > + > + QEMUGuest2 > + c7a5fdbd-edaf-9466-926a-d65c16db1809 > + 219100 > + 219100 > + 1 > + > + hvm > + > + > + > + destroy > + restart > + destroy > + > + /usr/bin/qemu > + > + > + > +
> + > + > + > + > + > + > + > + > + > + > + > + > +
> + > + > + > + > + > + > + > + > +
> + > + > + > + > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args > new file mode 100644 > index 0000000..e4b6e97 > --- /dev/null > +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args > @@ -0,0 +1,16 @@ > +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ > +/usr/bin/qemu -S -M \ > +pc -m 214 -smp 1 -nographic -nodefaults -monitor \ > +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ > +-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 -usb \ > +-drive file=/dev/HostVG/QEMUGuest2,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=iscsi://example.org:3260/iqn.1992-01.com.example,if=none,\ > +format=raw,id=drive-hostdev0 \ > +-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=4,\ > +drive=drive-hostdev0,id=hostdev0 \ > +-drive file=iscsi://example.org:3260/iqn.1992-01.com.example/1,if=none,\ > +format=raw,id=drive-hostdev1 \ > +-device scsi-generic,bus=scsi0.0,channel=0,scsi-id=2,lun=5,\ > +drive=drive-hostdev1,id=hostdev1 \ > +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 > diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml > new file mode 100644 > index 0000000..13c0930 > --- /dev/null > +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml > @@ -0,0 +1,40 @@ > + > + QEMUGuest2 > + c7a5fdbd-edaf-9466-926a-d65c16db1809 > + 219100 > + 219100 > + 1 > + > + hvm > + > + > + > + destroy > + restart > + destroy > + > + /usr/bin/qemu > + > + > + > +
> + > + > + > + > + > + > + > + > + > +
> + > + > + > + > + > +
> + > + > + > + > diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c > index 12ecabc..609c1bc 100644 > --- a/tests/qemuxml2argvtest.c > +++ b/tests/qemuxml2argvtest.c > @@ -1353,6 +1353,22 @@ mymain(void) > QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI, > QEMU_CAPS_DEVICE_SCSI_GENERIC, > QEMU_CAPS_DEVICE_SCSI_GENERIC_BOOTINDEX); > + DO_TEST("hostdev-scsi-lsi-iscsi", QEMU_CAPS_DRIVE, > + QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, > + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, > + QEMU_CAPS_DEVICE_SCSI_GENERIC); > + DO_TEST("hostdev-scsi-lsi-iscsi-auth", QEMU_CAPS_DRIVE, > + QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, > + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, > + QEMU_CAPS_DEVICE_SCSI_GENERIC); > + DO_TEST("hostdev-scsi-virtio-iscsi", QEMU_CAPS_DRIVE, > + QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, > + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI, > + QEMU_CAPS_DEVICE_SCSI_GENERIC); > + DO_TEST("hostdev-scsi-virtio-iscsi-auth", QEMU_CAPS_DRIVE, > + QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE, > + QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI, > + QEMU_CAPS_DEVICE_SCSI_GENERIC); > > DO_TEST("mlock-on", QEMU_CAPS_MLOCK); > DO_TEST_FAILURE("mlock-on", NONE); > diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c > index 451dedc..7d416d0 100644 > --- a/tests/qemuxml2xmltest.c > +++ b/tests/qemuxml2xmltest.c > @@ -361,6 +361,11 @@ mymain(void) > > DO_TEST_DIFFERENT("hostdev-scsi-autogen-address"); > > + DO_TEST("hostdev-scsi-lsi-iscsi"); > + DO_TEST("hostdev-scsi-lsi-iscsi-auth"); > + DO_TEST("hostdev-scsi-virtio-iscsi"); > + DO_TEST("hostdev-scsi-virtio-iscsi-auth"); > + > DO_TEST_DIFFERENT("s390-defaultconsole"); > > DO_TEST("pcihole64"); > From jferlan at redhat.com Mon Aug 11 20:27:16 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 11 Aug 2014 16:27:16 -0400 Subject: [Libvirt-cim] [PATCH v2 0/3] Wrong allocation size displayed for NFS volumes Message-ID: <1407788839-762-1-git-send-email-jferlan@redhat.com> Changes over v1 - different tact as more research discovers that the posix_fallocate() does not perform the correct pre-allocation of space for an NFS backed file/disk, some details of the findings can be found: http://www.redhat.com/archives/libvir-list/2014-August/msg00367.html The first patch in this series will refactor the safezero to allow for more fallback than the current code. Initially implemented as a series of three 'safezero()' functions in commit id 'c29d0929' using build conditionals to determine which of the 3 is being used. The refactored code will have one function that will make a series of calls rather the just failing on whatever is built into the system. The first is a global virFileFdPosixFallocate() with the build conditional controlling only whether the function runs or will just return -1. It will also be re-used by the Volume Resize code in a future patch. If on creation the virFileFdPosixFallocate() fails, attempts will be made to then try the mmap() method (if it exists), and then fall back to the slow, old, safewrite of zero filled buffers. The mmap function will follow the format of the posix_fallocate insomuch as if HAVE_MMAP is defined, then that will be attempted or a -1 will be returned immediately. The major change of this patch over the prior code is the fallback. One other minor change is if the virFileFdPosixFallocate() tries to call posix_fallocate() and fails, then a VIR_WARN will be used to indicate something went wrong. Previously, the code would return errno and eventually that would filter back to a caller which would use the errno in a sys error message. This I think only is odd when it comes to the resize path. The second patch looks to resolve the first issue discovered by: https://bugzilla.redhat.com/show_bug.cgi?id=1077068 It does this by checking the returned size/len of the file in the posix_fallocate() call and if it does not match a VIR_WARN will be posted and a failure returned allowing either the mmap or write of zero filled buffers to the file. The third patch changes the virStorageFileResize() logic to follow the safezero() logic with respect to build conditionals. Also, rather than reinvent the wheel, it will reuse the virFileFdPosixFallocate(). The new static API resizeSysFallocate() will return -1 if the build conditionals are not met. A current "downside" is by calling virFileFdPosixFallocate() twice (once directly and the other indirectly through safezero), the VIR_WARN will be displayed twice, but that should only affect someone trying to debug things. NOTE: Investigation and testing while creating this series also showed it's possible to modify the NFS Pool Start code to add a "-o wsize=4096" to the MOUNT command in order to force smaller write's. While that did fix the symptoms, the fix just didn't "feel right". The block size of the "source" export was 4096 bytes, while the block size of the "target" file was 1048576 bytes (current NFSv4 wsize default value when not specified). Whether those play into what posix_fallocate() does I am not sure, but if it does and that's fixed, then the way these patches are coded up - it won't matter. Compared to perhaps needing to revisit or document heavily how to set some new field in the pool XML source - this just seems more right. John Ferlan (3): virfile: Refactor safezero, introduce virFileFdPosixFallocate virfile: Check returned size from virFileFdPosixFallocate virstoragefile: Refactor virStorageFileResize src/libvirt_private.syms | 1 + src/util/virfile.c | 58 ++++++++++++++++++++++++++++++++++++++--------- src/util/virfile.h | 2 ++ src/util/virstoragefile.c | 52 +++++++++++++++++++++++++++--------------- 4 files changed, 84 insertions(+), 29 deletions(-) -- 1.9.3 From jferlan at redhat.com Mon Aug 11 20:27:17 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 11 Aug 2014 16:27:17 -0400 Subject: [Libvirt-cim] [PATCH v2 1/3] virfile: Refactor safezero, introduce virFileFdPosixFallocate In-Reply-To: <1407788839-762-1-git-send-email-jferlan@redhat.com> References: <1407788839-762-1-git-send-email-jferlan@redhat.com> Message-ID: <1407788839-762-2-git-send-email-jferlan@redhat.com> Currently the safezero() function uses build conditionals to choose either the posix_fallocate() or mmap() with a fallback to safewrite() in order to preallocate a file. This patch will modify the logic in order to allow fallbacks in the event that posix_fallocate() or the ftruncate()and mmap() doesn't work properly. The fallback will be to use the slow safewrite of zero filled buffers to the file. This patch also introduces virFileFdPosixFallocate() so that it can be used by the resize code rather than having two separate functions Signed-off-by: John Ferlan --- src/libvirt_private.syms | 1 + src/util/virfile.c | 37 +++++++++++++++++++++++++++---------- src/util/virfile.h | 2 ++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 08111d4..5556d31 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1278,6 +1278,7 @@ virFileDirectFdFlag; virFileExists; virFileFclose; virFileFdopen; +virFileFdPosixFallocate; virFileFindHugeTLBFS; virFileFindMountPoint; virFileFindResource; diff --git a/src/util/virfile.c b/src/util/virfile.c index f9efc65..7f03cbf 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1034,26 +1034,26 @@ safewrite(int fd, const void *buf, size_t count) return nwritten; } -#ifdef HAVE_POSIX_FALLOCATE int -safezero(int fd, off_t offset, off_t len) +virFileFdPosixFallocate(int fd, off_t offset, off_t len) { +#ifdef HAVE_POSIX_FALLOCATE int ret = posix_fallocate(fd, offset, len); if (ret == 0) return 0; + VIR_WARN("Failed to pre-allocate '%lu' bytes with return value '%d'", + len, ret); errno = ret; +#endif /* HAVE_POSIX_FALLOCATE */ return -1; } -#else - -int -safezero(int fd, off_t offset, off_t len) +static int +safezero_mmap(int fd, off_t offset, off_t len) { +#ifdef HAVE_MMAP int r; char *buf; - unsigned long long remain, bytes; -# ifdef HAVE_MMAP static long pagemask = 0; off_t map_skip; @@ -1080,7 +1080,16 @@ safezero(int fd, off_t offset, off_t len) /* fall back to writing zeroes using safewrite if mmap fails (for * example because of virtual memory limits) */ -# endif /* HAVE_MMAP */ +#endif /* HAVE_MMAP */ + return -1; +} + +static int +safezero_slow(int fd, off_t offset, off_t len) +{ + int r; + char *buf; + unsigned long long remain, bytes; if (lseek(fd, offset, SEEK_SET) < 0) return -1; @@ -1111,8 +1120,16 @@ safezero(int fd, off_t offset, off_t len) VIR_FREE(buf); return 0; } -#endif /* HAVE_POSIX_FALLOCATE */ +int +safezero(int fd, off_t offset, off_t len) +{ + if (virFileFdPosixFallocate(fd, offset, len) == 0) + return 0; + if (safezero_mmap(fd, offset, len) == 0) + return 0; + return safezero_slow(fd, offset, len); +} #if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R /* search /proc/mounts for mount point of *type; return pointer to diff --git a/src/util/virfile.h b/src/util/virfile.h index 403d0ba..29a1776 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -41,6 +41,8 @@ typedef enum { ssize_t saferead(int fd, void *buf, size_t count) ATTRIBUTE_RETURN_CHECK; ssize_t safewrite(int fd, const void *buf, size_t count) ATTRIBUTE_RETURN_CHECK; +int virFileFdPosixFallocate(int fd, off_t offset, off_t len) + ATTRIBUTE_RETURN_CHECK; int safezero(int fd, off_t offset, off_t len) ATTRIBUTE_RETURN_CHECK; -- 1.9.3 From jferlan at redhat.com Mon Aug 11 20:27:18 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 11 Aug 2014 16:27:18 -0400 Subject: [Libvirt-cim] [PATCH v2 2/3] virfile: Check returned size from virFileFdPosixFallocate In-Reply-To: <1407788839-762-1-git-send-email-jferlan@redhat.com> References: <1407788839-762-1-git-send-email-jferlan@redhat.com> Message-ID: <1407788839-762-3-git-send-email-jferlan@redhat.com> https://bugzilla.redhat.com/show_bug.cgi?id=1077068 Add an fstat check to virFileFdPosixFallocate and fail if the allocated size doesn't match the expected value. Since the failure will fall back to using safewrite(), just leave a VIR_WARN message indicating the failure and some entrails for determining why the failure occurred. It seems for an NFS file at least the allocation may not work properly depending on the NFS configuration. Signed-off-by: John Ferlan --- src/util/virfile.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 7f03cbf..3b87d9f 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1038,9 +1038,28 @@ int virFileFdPosixFallocate(int fd, off_t offset, off_t len) { #ifdef HAVE_POSIX_FALLOCATE + struct stat sb; + off_t newlen; int ret = posix_fallocate(fd, offset, len); - if (ret == 0) + if (ret == 0) { + /* Let's make sure the new size matches our expectations */ + if (fstat(fd, &sb) < 0) + return -1; +# ifndef WIN32 + newlen = (unsigned long long)sb.st_blocks * + (unsigned long long)DEV_BSIZE; +# else + newlen = sb.st_size; +# endif + if (newlen != len) { + VIR_WARN("posix_fallocate only allocated '%lu' bytes, expected " + "'%lu' byte file (blocks=%lu bsize=%d).", + newlen, len, sb.st_blocks, DEV_BSIZE); + return -1; + } + return 0; + } VIR_WARN("Failed to pre-allocate '%lu' bytes with return value '%d'", len, ret); errno = ret; -- 1.9.3 From jferlan at redhat.com Mon Aug 11 20:27:19 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 11 Aug 2014 16:27:19 -0400 Subject: [Libvirt-cim] [PATCH v2 3/3] virstoragefile: Refactor virStorageFileResize In-Reply-To: <1407788839-762-1-git-send-email-jferlan@redhat.com> References: <1407788839-762-1-git-send-email-jferlan@redhat.com> Message-ID: <1407788839-762-4-git-send-email-jferlan@redhat.com> Currently virStorageFileResize() function uses build conditionals to choose either the posix_fallocate() or mmap() with no fallback in order to preallocate the space in the newly resized file. This patch will modify the logic in order to allow fallbacks in the event that posix_fallocate() or the sys_fallocate syscall() doesn't work properly. The fallback will be to use the slow safewrite of zero filled buffers to the file. Use the virFileFdPosixFallocate() rather than a local function. Signed-off-by: John Ferlan --- src/util/virstoragefile.c | 52 +++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 5b6b2f5..4d37de1 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1086,6 +1086,39 @@ virStorageFileChainGetBroken(virStorageSourcePtr chain, return 0; } +static int +resizeSysFallocate(const char *path, + int fd, + off_t offset, + off_t len) +{ + int rc = -1; +#if HAVE_SYS_SYSCALL_H && defined(SYS_fallocate) + if ((rc = syscall(SYS_fallocate, fd, 0, offset, len)) != 0) { + virReportSystemError(errno, + _("Failed to pre-allocate space for " + "file '%s'"), path); + } +#endif + return rc; +} + +static int +doResize(const char *path, + int fd, + off_t offset, + off_t len) +{ + if (virFileFdPosixFallocate(fd, offset, len) == 0 || + resizeSysFallocate(path, fd, offset, len) == 0 || + safezero(fd, offset, len) == 0) + return 0; + + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("preallocate is not supported on this platform")); + return -1; +} + /** * virStorageFileResize: @@ -1113,25 +1146,8 @@ virStorageFileResize(const char *path, } if (pre_allocate) { -#if HAVE_POSIX_FALLOCATE - if ((rc = posix_fallocate(fd, offset, len)) != 0) { - virReportSystemError(rc, - _("Failed to pre-allocate space for " - "file '%s'"), path); - goto cleanup; - } -#elif HAVE_SYS_SYSCALL_H && defined(SYS_fallocate) - if (syscall(SYS_fallocate, fd, 0, offset, len) != 0) { - virReportSystemError(errno, - _("Failed to pre-allocate space for " - "file '%s'"), path); + if (doResize(path, fd, offset, len) < 0) goto cleanup; - } -#else - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("preallocate is not supported on this platform")); - goto cleanup; -#endif } else { if (ftruncate(fd, capacity) < 0) { virReportSystemError(errno, -- 1.9.3 From jferlan at redhat.com Mon Aug 11 20:28:29 2014 From: jferlan at redhat.com (John Ferlan) Date: Mon, 11 Aug 2014 16:28:29 -0400 Subject: [Libvirt-cim] [PATCH v2 0/3] Wrong allocation size displayed for NFS volumes In-Reply-To: <1407788839-762-1-git-send-email-jferlan@redhat.com> References: <1407788839-762-1-git-send-email-jferlan@redhat.com> Message-ID: <53E9276D.90304@redhat.com> It's just not my month.... Wrong list again John