add network disk support
PATCH 1/1 add network disk support
This patch adds network disk support to libvirt/QEMU. The currently supported protcols are nbd, rbd, and sheepdog. The XML syntax is like this:
<disk type="network" device="disk">
<driver name="qemu" type="raw" />
<source protocol='rbd|sheepdog|nbd' name="...some image identifier...">
<host name="mon1.example.org" port="6000">
<host name="mon2.example.org" port="6000">
<host name="mon3.example.org" port="6000">
</source>
<target dev="vda" bus="virtio" />
</disk>---
This patch addresses the discussion on
https://www.redhat.com/archives/libvir-list/2010-November/msg00759.html
Josh mentioned that the monitor hostnames of RBD can be set through the environment variables, but I couldn't find any documentations about it, so the monitors are not set in this patch. I hope someone who is familiar with RBD implements it.
I appreciate any feedback.
Thanks,
Kazutaka
docs/schemas/domain.rng | 31 +++++++++ src/conf/domain_conf.c | 68 +++++++++++++++++-- src/conf/domain_conf.h | 20 ++++++ src/qemu/qemu_conf.c | 169 +++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 279 insertions(+), 9 deletions(-)
docs/schemas/domain.rng +31 -0
@@ -612,6 +612,37 @@ <ref name="diskspec"/> </interleave> </group> + <group> + <attribute name="type"> + <value>network</value> + </attribute> + <interleave> + <optional> + <element name="source"> + <attribute name="protocol"> + <choice> + <value>nbd</value> + <value>rbd</value> + <value>sheepdog</value> + </choice> + </attribute> + <attribute name="name"/> + <zeroOrMore> + <element name="host"> + <attribute name="name"> + <ref name="genericName"/> + </attribute> + <attribute name="port"> + <ref name="unsignedInt"/> + </attribute> + </element> + </zeroOrMore> + <empty/> + </element> + </optional> + <ref name="diskspec"/> + </interleave> + </group> <ref name="diskspec"/> </choice> </element>
src/conf/domain_conf.c +63 -5
140 lines not on this page · raw message
src/conf/domain_conf.h +20 -0
@@ -120,6 +120,7 @@ enum virDomainDiskType {VIR_DOMAIN_DISK_TYPE_BLOCK ,VIR_DOMAIN_DISK_TYPE_FILE ,VIR_DOMAIN_DISK_TYPE_DIR , +VIR_DOMAIN_DISK_TYPE_NETWORK , VIR_DOMAIN_DISK_TYPE_LAST };
@@ -164,6 +165,21 @@ enum virDomainDiskErrorPolicy { VIR_DOMAIN_DISK_ERROR_POLICY_LAST }; +enum virDomainDiskProtocol { +VIR_DOMAIN_DISK_PROTOCOL_NBD , +VIR_DOMAIN_DISK_PROTOCOL_RBD , +VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG , + +VIR_DOMAIN_DISK_PROTOCOL_LAST +}; + +typedef struct _virDomainDiskHostDef virDomainDiskHostDef ; +typedef virDomainDiskHostDef *virDomainDiskHostDefPtr ; +struct _virDomainDiskHostDef { +char *name; +char *port; +}; +/* Stores the virtual disk configuration */ typedef struct _virDomainDiskDef virDomainDiskDef ;typedef virDomainDiskDef *virDomainDiskDefPtr ;
@@ -173,6 +189,9 @@ struct _virDomainDiskDef {int bus;char *src;char *dst; +int protocol; +int nhosts; +virDomainDiskHostDefPtr hosts;char *driverName;char *driverType;char *serial;
@@ -1237,6 +1256,7 @@ VIR_ENUM_DECL(virDomainDiskDevice) VIR_ENUM_DECL(virDomainDiskBus) VIR_ENUM_DECL(virDomainDiskCache) VIR_ENUM_DECL(virDomainDiskErrorPolicy) +VIR_ENUM_DECL(virDomainDiskProtocol) VIR_ENUM_DECL(virDomainController) VIR_ENUM_DECL(virDomainControllerModel) VIR_ENUM_DECL(virDomainFS)
src/qemu/qemu_conf.c +165 -4
205 lines not on this page · raw message
Signature · 1 line
1.7.1
Quoted 4 lines · MORITA Kazutaka
This patch adds network disk support to libvirt/QEMU. The currently supported protcols are nbd, rbd, and sheepdog. The XML syntax is like this:
Quoted 9 lines
<disk type="network" device="disk">
<driver name="qemu" type="raw" />
<source protocol='rbd|sheepdog|nbd' name="...some image identifier...">
<host name="mon1.example.org" port="6000">
<host name="mon2.example.org" port="6000">
<host name="mon3.example.org" port="6000">
</source>
<target dev="vda" bus="virtio" />
</disk>This design looks good to me.
Quoted 14 lines
Signed-off-by MORITA Kazutaka <[email protected]>---
This patch addresses the discussion on
https://www.redhat.com/archives/libvir-list/2010-November/msg00759.htmlJosh mentioned that the monitor hostnames of RBD can be set through the environment variables, but I couldn't find any documentations about it, so the monitors are not set in this patch. I hope someone who is familiar with RBD implements it.
src/conf/domain_conf.c +0
-0@@ -1620,6 +1629,30 @@ virDomainDiskDefParseXML(virCapsPtr caps,case VIR_DOMAIN_DISK_TYPE_DIR :
src/conf/domain_conf.c virDomainDiskDefParseXML(virCapsPtr caps, · line 1639
Quoted 10 lines
src/conf/domain_conf.c +8
-0source =virXMLPropString (cur,"dir" );break ; +case VIR_DOMAIN_DISK_TYPE_NETWORK : + protocol =virXMLPropString (cur,"protocol" ); +if (protocol ==NULL ) { +virDomainReportError (VIR_ERR_XML_ERROR , +"%s" ,_ ("missing protocol type" )); +break ; + } + def->protocol =virDomainDiskProtocolTypeFromString (protocol);
Should check for def->protocal < 0 & raise an error, which would indicate that 'protocol' was not one of the expected values.
src/conf/domain_conf.c virDomainDiskDefParseXML(virCapsPtr caps, · line 1651
Quoted 12 lines
src/conf/domain_conf.c +12
-0+ source =virXMLPropString (cur,"name" ); + host = cur->children; +while (host !=NULL ) { +if (host->type ==XML_ELEMENT_NODE && +xmlStrEqual (host->name,BAD_CAST "host" )) { +if (VIR_REALLOC_N (hosts, def->nhosts +1 ) <0 ) { +virReportOOMError (); + goto error; + } + hosts[def->nhosts].name =virXMLPropString (host,"name" ); + hosts[def->nhosts].port =virXMLPropString (host,"port" ); + def->nhosts++;
Ought to check for NULLs returned by virXMLPropString here I think.
Quoted 26 lines
src/conf/domain_conf.c +7
-1+ } + host = host->next; + } +break ;default : virDomainReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk type %s"),@@ -1685,7 +1718,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,/* Only CDROM and Floppy devices are allowed missing source path * to indicate no media present */ -if (source ==NULL && +if (source ==NULL && hosts ==NULL && def->device !=VIR_DOMAIN_DISK_DEVICE_CDROM && def->device !=VIR_DOMAIN_DISK_DEVICE_FLOPPY ) { virDomainReportError(VIR_ERR_NO_SOURCE,@@ -1791,6 +1824,8 @@ virDomainDiskDefParseXML(virCapsPtr caps, source =NULL ; def->dst = target; target =NULL ; + def->hosts = hosts; + hosts =NULL ; def->driverName = driverName; driverName =NULL ; def->driverType = driverType;
src/conf/domain_conf.c cleanup: · line 1857
Quoted 4 lines
src/conf/domain_conf.c +1
-0@@ -1819,6 +1854,8 @@ cleanup:VIR_FREE (type);VIR_FREE (target);VIR_FREE (source); +VIR_FREE (hosts);
I think you need to free the fields inside 'hosts' too, otherwise we'd leak memory for the port + host strings in the error path.
src/qemu/qemu_conf.c qemuBuildDriveStr(virDomainDiskDefPtr disk, · line 2717
Quoted 10 lines
src/qemu/qemu_conf.c +1
-1@@ -2714,7 +2714,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,break ; } -if (disk->src) { +if (disk->src || disk->nhosts >0 ) {
If you check for nhosts > 0 here
Quoted 14 lines
src/qemu/qemu_conf.c +7
-0if (disk->type ==VIR_DOMAIN_DISK_TYPE_DIR ) {/* QEMU only supports magic FAT format for now */ if (disk->driverType &&@@ -2733,6 +2733,24 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,virBufferVSprintf (&opt,"file=fat:floppy:%s," , disk->src); else virBufferVSprintf(&opt, "file=fat:%s,", disk->src); + }else if (disk->type ==VIR_DOMAIN_DISK_TYPE_NETWORK ) { +switch (disk->protocol) { +case VIR_DOMAIN_DISK_PROTOCOL_NBD : +virBufferVSprintf (&opt,"file=nbd:%s:%s," , + disk->hosts->name, disk->hosts->port); +break ; +case VIR_DOMAIN_DISK_PROTOCOL_RBD :
src/qemu/qemu_conf.c qemuBuildDriveStr(virDomainDiskDefPtr disk, · line 2752
Quoted 10 lines
src/qemu/qemu_conf.c +10
-0+virBufferVSprintf (&opt,"file=rbd:%s," , disk->src); +break ; +case VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG : +if (disk->nhosts >0 ) +virBufferVSprintf (&opt,"file=sheepdog:%s:%s:%s," , + disk->hosts->name, disk->hosts->port, + disk->src); +else +virBufferVSprintf (&opt,"file=sheepdog:%s," , disk->src); +break ;
This else branch for sheepdog will never execute. So I think it is better to check the nhosts value in each of these conditionals. eg We should report an error if nhosts == 0, or nhosts > 1 for NBD since it only wants 1 host. Likewise for other protocols as nedeed.
Quoted 15 lines
src/qemu/qemu_conf.c +10
-1@@ -5794,7 +5830,67 @@ qemuParseCommandLineDisk(virCapsPtr caps, values[i] =NULL ;if (STRPREFIX (def->src,"/dev/" )) def->type =VIR_DOMAIN_DISK_TYPE_BLOCK ; -else +else if (STRPREFIX (def->src,"nbd:" )) { +char *host, *port; + + def->type =VIR_DOMAIN_DISK_TYPE_NETWORK ; + host = def->src +strlen ("nbd:" ); + port =strchr (host,':' ); +if (!port) { + def =NULL ; +qemuReportError (VIR_ERR_INTERNAL_ERROR , +_ ("cannot parse nbd filename '%s'" ), def->src);
src/qemu/qemu_conf.c qemuParseCommandLineDisk(virCapsPtr caps, · line 5852
Quoted 10 lines
src/qemu/qemu_conf.c +10
-0+ goto cleanup; + } + *port++ ='\0' ; +if (VIR_ALLOC (def->hosts) <0 ) { +virReportOOMError (); + goto cleanup; + } + def->nhosts =1 ; + def->hosts->name =strdup (host); + def->hosts->port =strdup (port);
Should check for NULL in both of these strdup cases.
src/qemu/qemu_conf.c qemuParseCommandLineDisk(virCapsPtr caps, · line 5860
Quoted 8 lines
src/qemu/qemu_conf.c +8
-0+ +VIR_FREE (def->src); + def->src =NULL ; + }else if (STRPREFIX (def->src,"rbd:" )) { +char *p = def->src; + + def->type =VIR_DOMAIN_DISK_TYPE_NETWORK ; + def->src =strdup (p +strlen ("rbd:" ));
And this one, and a few more strdup's later in the patch.
Regards,
Daniel
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/1 add network disk support
This patch adds network disk support to libvirt/QEMU. The currently supported protocols are nbd, rbd, and sheepdog. The XML syntax is like this:
<disk type="network" device="disk">
<driver name="qemu" type="raw" />
<source protocol='rbd|sheepdog|nbd' name="...some image identifier...">
<host name="mon1.example.org" port="6000">
<host name="mon2.example.org" port="6000">
<host name="mon3.example.org" port="6000">
</source>
<target dev="vda" bus="virtio" />
</disk>---
Hi,
Thanks for your comments, Daniel. Here is a fixed version.
Changes from v1 to v2 are:
- check whether the XML input is valid or not more strictly
- fix memory leak in the error path
- add NULL check of the return value of strdup()
Thanks,
Kazutaka
docs/schemas/domain.rng | 31 +++++++ src/conf/domain_conf.c | 95 +++++++++++++++++++- src/conf/domain_conf.h | 20 ++++ src/qemu/qemu_conf.c | 221 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 358 insertions(+), 9 deletions(-)
docs/schemas/domain.rng +31 -0
@@ -612,6 +612,37 @@ <ref name="diskspec"/> </interleave> </group> + <group> + <attribute name="type"> + <value>network</value> + </attribute> + <interleave> + <optional> + <element name="source"> + <attribute name="protocol"> + <choice> + <value>nbd</value> + <value>rbd</value> + <value>sheepdog</value> + </choice> + </attribute> + <attribute name="name"/> + <zeroOrMore> + <element name="host"> + <attribute name="name"> + <ref name="genericName"/> + </attribute> + <attribute name="port"> + <ref name="unsignedInt"/> + </attribute> + </element> + </zeroOrMore> + <empty/> + </element> + </optional> + <ref name="diskspec"/> + </interleave> + </group> <ref name="diskspec"/> </choice> </element>
src/conf/domain_conf.c +90 -5
167 lines not on this page · raw message
src/conf/domain_conf.h +20 -0
@@ -120,6 +120,7 @@ enum virDomainDiskType {VIR_DOMAIN_DISK_TYPE_BLOCK ,VIR_DOMAIN_DISK_TYPE_FILE ,VIR_DOMAIN_DISK_TYPE_DIR , +VIR_DOMAIN_DISK_TYPE_NETWORK , VIR_DOMAIN_DISK_TYPE_LAST };
@@ -164,6 +165,21 @@ enum virDomainDiskErrorPolicy { VIR_DOMAIN_DISK_ERROR_POLICY_LAST }; +enum virDomainDiskProtocol { +VIR_DOMAIN_DISK_PROTOCOL_NBD , +VIR_DOMAIN_DISK_PROTOCOL_RBD , +VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG , + +VIR_DOMAIN_DISK_PROTOCOL_LAST +}; + +typedef struct _virDomainDiskHostDef virDomainDiskHostDef ; +typedef virDomainDiskHostDef *virDomainDiskHostDefPtr ; +struct _virDomainDiskHostDef { +char *name; +char *port; +}; +/* Stores the virtual disk configuration */ typedef struct _virDomainDiskDef virDomainDiskDef ;typedef virDomainDiskDef *virDomainDiskDefPtr ;
@@ -173,6 +189,9 @@ struct _virDomainDiskDef {int bus;char *src;char *dst; +int protocol; +int nhosts; +virDomainDiskHostDefPtr hosts;char *driverName;char *driverType;char *serial;
@@ -1237,6 +1256,7 @@ VIR_ENUM_DECL(virDomainDiskDevice) VIR_ENUM_DECL(virDomainDiskBus) VIR_ENUM_DECL(virDomainDiskCache) VIR_ENUM_DECL(virDomainDiskErrorPolicy) +VIR_ENUM_DECL(virDomainDiskProtocol) VIR_ENUM_DECL(virDomainController) VIR_ENUM_DECL(virDomainControllerModel) VIR_ENUM_DECL(virDomainFS)
src/qemu/qemu_conf.c +217 -4
257 lines not on this page · raw message
Signature · 1 line
1.7.1
cover rbd network disk support
Here are patches on top of Kazutaka's v2 to add RBD support and fix some general network disk problems. There's also a test for each type of network disk.
Josh Durgin (2):
qemu: Add RBD support and some network disk fixes
tests: Add tests for network disks
docs/schemas/domain.rng | 11 ++- src/conf/domain_conf.c | 25 +++- src/conf/domain_conf.h | 1 + src/qemu/qemu_conf.c | 143 ++++++++++++++++++-- tests/qemuargv2xmltest.c | 3 + .../qemuxml2argv-disk-drive-network-nbd.args | 1 + .../qemuxml2argv-disk-drive-network-nbd.xml | 32 +++++ .../qemuxml2argv-disk-drive-network-rbd.args | 1 + .../qemuxml2argv-disk-drive-network-rbd.xml | 34 +++++ .../qemuxml2argv-disk-drive-network-sheepdog.args | 1 + .../qemuxml2argv-disk-drive-network-sheepdog.xml | 32 +++++ tests/qemuxml2argvtest.c | 6 + 12 files changed, 275 insertions(+), 15 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml
A message that is not in the archive (sent off-list or not yet received): 1291620249-19645-1-git-send-email-morita.kazutaka-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org
PATCH 1/2 qemu: Add RBD support and some network disk fixes
Changes common to all network disks:
-Make source name optional in the domain schema, since NBD doesn't use it
-Add a hostName type to the domain schema, and use it instead of genericName, which doesn't include . -Don't leak host names or ports
-Set the source protocol in qemuParseCommandline
--- docs/schemas/domain.rng | 11 +++- src/conf/domain_conf.c | 25 +++++++- src/conf/domain_conf.h | 1 + src/qemu/qemu_conf.c | 143 ++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 165 insertions(+), 15 deletions(-)
docs/schemas/domain.rng +9 -2
@@ -626,11 +626,13 @@ <value>sheepdog</value> </choice> </attribute> - <attribute name="name"/> + <optional> + <attribute name="name"/> + </optional> <zeroOrMore> <element name="host"> <attribute name="name"> - <ref name="genericName"/> + <ref name="hostName"/> </attribute> <attribute name="port"> <ref name="unsignedInt"/>
@@ -2024,6 +2026,11 @@ <param name="minInclusive">1</param> </data> </define> + <define name="hostName"> + <data type="string"> + <param name="pattern">[a-zA-Z0-9\.\-]+</param> + </data> + </define> <define name="PortNumber"> <data type="short"> <param name="minInclusive">-1</param>
src/conf/domain_conf.c +21 -4
@@ -508,21 +508,34 @@ void virDomainInputDefFree(virDomainInputDefPtr def)void virDomainDiskDefFree (virDomainDiskDefPtr def) { +unsigned int i; +if (!def)return ;VIR_FREE (def->serial);VIR_FREE (def->src); -VIR_FREE (def->hosts);VIR_FREE (def->dst);VIR_FREE (def->driverName);VIR_FREE (def->driverType);virStorageEncryptionFree (def->encryption);virDomainDeviceInfoClear (&def->info); +for (i =0 ; i < def->nhosts ; i++) +virDomainDiskHostDefFree (&def->hosts[i]); +VIR_FREE (def); } +void virDomainDiskHostDefFree (virDomainDiskHostDefPtr def) +{ +if (!def) +return ; + +VIR_FREE (def->name); +VIR_FREE (def->port); +} +void virDomainControllerDefFree (virDomainControllerDefPtr def) {if (!def)
@@ -1643,7 +1656,12 @@ virDomainDiskDefParseXML(virCapsPtr caps, protocol); goto error; } - source =virXMLPropString (cur,"name" ); +if (!(source =virXMLPropString (cur,"name" )) && + def->protocol !=VIR_DOMAIN_DISK_PROTOCOL_NBD ) { +virDomainReportError (VIR_ERR_INTERNAL_ERROR , +_ ("missing name for disk source" )); + goto error; + } host = cur->children;while (host !=NULL ) { if (host->type == XML_ELEMENT_NODE &&
@@ -1876,8 +1894,7 @@ cleanup:VIR_FREE (target);VIR_FREE (source);while (nhosts >0 ) { -VIR_FREE (hosts[nhosts -1 ].name); -VIR_FREE (hosts[nhosts -1 ].port); +virDomainDiskHostDefFree (&hosts[nhosts -1 ]); nhosts--; }VIR_FREE (hosts);
src/conf/domain_conf.h +1 -0
@@ -1070,6 +1070,7 @@ virDomainObjPtr virDomainFindByName(const virDomainObjListPtr doms,void virDomainGraphicsDefFree (virDomainGraphicsDefPtr def);void virDomainInputDefFree (virDomainInputDefPtr def);void virDomainDiskDefFree (virDomainDiskDefPtr def); +void virDomainDiskHostDefFree (virDomainDiskHostDefPtr def);void virDomainControllerDefFree (virDomainControllerDefPtr def);void virDomainFSDefFree (virDomainFSDefPtr def);void virDomainNetDefFree (virDomainNetDefPtr def);
src/qemu/qemu_conf.c +134 -9
228 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Re: [libvirt] [PATCH 1/2] qemu: Add RBD support and some network disk fixes
Quoted 7 lines · Josh Durgin
Changes common to all network disks:
(quoted diff) +0
-4-Make source name optional in the domain schema, since NBD doesn't use it -Add a hostName type to the domain schema, and use it instead of genericName, which doesn't include . -Don't leak host names or ports -Set the source protocol in qemuParseCommandline
Quoted 7 lines
Signed-off-by Josh Durgin <[email protected]>--- docs/schemas/domain.rng | 11 +++- src/conf/domain_conf.c | 25 +++++++- src/conf/domain_conf.h | 1 + src/qemu/qemu_conf.c | 143 ++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 165 insertions(+), 15 deletions(-)
ACK
Daniel
PATCH 2/2 tests: Add tests for network disks
In reply to MORITA Kazutaka--- tests/qemuargv2xmltest.c | 3 ++ .../qemuxml2argv-disk-drive-network-nbd.args | 1 + .../qemuxml2argv-disk-drive-network-nbd.xml | 32 ++++++++++++++++++ .../qemuxml2argv-disk-drive-network-rbd.args | 1 + .../qemuxml2argv-disk-drive-network-rbd.xml | 34 ++++++++++++++++++++ .../qemuxml2argv-disk-drive-network-sheepdog.args | 1 + .../qemuxml2argv-disk-drive-network-sheepdog.xml | 32 ++++++++++++++++++ tests/qemuxml2argvtest.c | 6 +++ 8 files changed, 110 insertions(+), 0 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml
tests/qemuargv2xmltest.c +3 -0
@@ -173,6 +173,9 @@ mymain(int argc, char **argv)DO_TEST ("disk-drive-cache-v2-wt" );DO_TEST ("disk-drive-cache-v2-wb" );DO_TEST ("disk-drive-cache-v2-none" ); +DO_TEST ("disk-drive-network-nbd" ); +DO_TEST ("disk-drive-network-rbd" ); +DO_TEST ("disk-drive-network-sheepdog" );DO_TEST ("disk-usb" );DO_TEST ("graphics-vnc" );
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args new file +1 -0
@@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive file=nbd:example.org:6000,if=virtio,format=raw -net none -serial none -parallel none -usb
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml new file +32 -0
@@ -0,0 +1,32 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</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' unit='0'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='nbd'> + <host name='example.org' port='6000'/> + </source> + <target dev='vda' bus='virtio'/> + </disk> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain>
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args new file +1 -0
@@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test CEPH_ARGS=-m mon1.example.org:6321,mon2.example.org:6322,mon3.example.org:6322 /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive file=rbd:pool/image,if=virtio,format=raw -net none -serial none -parallel none -usb
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml new file +34 -0
@@ -0,0 +1,34 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</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' unit='0'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='rbd' name='pool/image'> + <host name='mon1.example.org' port='6321'/> + <host name='mon2.example.org' port='6322'/> + <host name='mon3.example.org' port='6322'/> + </source> + <target dev='vda' bus='virtio'/> + </disk> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain>
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args new file +1 -0
@@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive file=sheepdog:example.org:6000:image,if=virtio,format=raw -net none -serial none -parallel none -usb
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml new file +32 -0
@@ -0,0 +1,32 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory>219200</memory> + <currentMemory>219200</currentMemory> + <vcpu>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</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' unit='0'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='sheepdog' name='image'> + <host name='example.org' port='6000'/> + </source> + <target dev='vda' bus='virtio'/> + </disk> + <controller type='ide' index='0'/> + <memballoon model='virtio'/> + </devices> +</domain>
tests/qemuxml2argvtest.c +6 -0
@@ -302,6 +302,12 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_DRIVE_CACHE_V2 | QEMUD_CMD_FLAG_DRIVE_FORMAT, false);DO_TEST ("disk-drive-cache-v2-none" ,QEMUD_CMD_FLAG_DRIVE |QEMUD_CMD_FLAG_DRIVE_CACHE_V2 |QEMUD_CMD_FLAG_DRIVE_FORMAT , false); +DO_TEST ("disk-drive-network-nbd" ,QEMUD_CMD_FLAG_DRIVE | +QEMUD_CMD_FLAG_DRIVE_FORMAT , false); +DO_TEST ("disk-drive-network-rbd" ,QEMUD_CMD_FLAG_DRIVE | +QEMUD_CMD_FLAG_DRIVE_FORMAT , false); +DO_TEST ("disk-drive-network-sheepdog" ,QEMUD_CMD_FLAG_DRIVE | +QEMUD_CMD_FLAG_DRIVE_FORMAT , false);DO_TEST ("disk-usb" ,0 , false);DO_TEST ("disk-usb-device" ,QEMUD_CMD_FLAG_DRIVE |QEMUD_CMD_FLAG_DEVICE |QEMUD_CMD_FLAG_NODEFCONFIG , false);
Signature · 1 line
1.5.6.5
Re: [libvirt] [PATCH 2/2] tests: Add tests for network disks
Quoted 18 lines · Josh Durgin
Signed-off-by Josh Durgin <[email protected]>--- tests/qemuargv2xmltest.c | 3 ++ .../qemuxml2argv-disk-drive-network-nbd.args | 1 + .../qemuxml2argv-disk-drive-network-nbd.xml | 32 ++++++++++++++++++ .../qemuxml2argv-disk-drive-network-rbd.args | 1 + .../qemuxml2argv-disk-drive-network-rbd.xml | 34 ++++++++++++++++++++ .../qemuxml2argv-disk-drive-network-sheepdog.args | 1 + .../qemuxml2argv-disk-drive-network-sheepdog.xml | 32 ++++++++++++++++++ tests/qemuxml2argvtest.c | 6 +++ 8 files changed, 110 insertions(+), 0 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml
ACK
Daniel
Quoted 28 lines · MORITA Kazutaka
This patch adds network disk support to libvirt/QEMU. The currently supported protocols are nbd, rbd, and sheepdog. The XML syntax is like this:
<disk type="network" device="disk"> <driver name="qemu" type="raw" /> <source protocol='rbd|sheepdog|nbd' name="...some image identifier..."> <host name="mon1.example.org" port="6000"> <host name="mon2.example.org" port="6000"> <host name="mon3.example.org" port="6000"> </source> <target dev="vda" bus="virtio" /> </disk>Signed-off-by MORITA Kazutaka <[email protected]>---
Hi,
Thanks for your comments, Daniel. Here is a fixed version.
Changes from v1 to v2 are:
- check whether the XML input is valid or not more strictly
- fix memory leak in the error path
- add NULL check of the return value ofstrdup()Thanks,
Quoted 8 lines
Kazutaka
docs/schemas/domain.rng | 31 +++++++ src/conf/domain_conf.c | 95 +++++++++++++++++++- src/conf/domain_conf.h | 20 ++++ src/qemu/qemu_conf.c | 221 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 358 insertions(+), 9 deletions(-)
ACK
Daniel
Quoted 15 lines · Daniel P. Berrange
Quoted 14 lines · MORITA Kazutaka
This patch adds network disk support to libvirt/QEMU. The currently supported protocols are nbd, rbd, and sheepdog. The XML syntax is like this:
<disk type="network" device="disk"> <driver name="qemu" type="raw" /> <source protocol='rbd|sheepdog|nbd' name="...some image identifier..."> <host name="mon1.example.org" port="6000"> <host name="mon2.example.org" port="6000"> <host name="mon3.example.org" port="6000"> </source> <target dev="vda" bus="virtio" /> </disk>
Quoted 1 line
Quoted 1 line
docs/schemas/domain.rng | 31 +++++++
Hmm; missing a corresponding update to docs/formatdomain.html.in to document the new XML.
Quoted 1 line
ACK
NACK. After applying this patch, I get 'make check' failures:
TEST: vmx2xmltest
/bin/sh: line 5: 15285 Segmentation fault (core dumped)
abs_top_builddir=cd '..'; pwd abs_top_srcdir=cd '..'; pwd abs_builddir=cd '.'; pwd abs_srcdir=cd '.'; pwd CONFIG_HEADER="cd '..'; pwd/config.h" PATH="$abs_top_builddir/src:$abs_top_builddir/daemon:$abs_top_builddir/tools:$PATH" SHELL="/bin/sh" LIBVIRT_DRIVER_DIR="/home/remote/eblake/libvirt/src/.libs" LC_ALL=C ${dir}$tst
FAIL: vmx2xmltest
TEST: xml2vmxtest
...!!!!!!!!!!...............!!!!!!!!!.. 39 FAIL
I haven't looked into root cause. Kazutaka, would you mind preparing a v3?
Signature · 2 lines
Eric Blake [email protected] +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Quoted 7 lines · Eric Blake
Quoted 5 lines · Daniel P. Berrange
Quoted 4 lines · MORITA Kazutaka
This patch adds network disk support to libvirt/QEMU. The currently supported protocols are nbd, rbd, and sheepdog. The XML syntax is like this:
Quoted 6 lines
Quoted 1 line
ACK
NACK. After applying this patch, I get 'make check' failures:
TEST: vmx2xmltest
/bin/sh: line 5: 15285 Segmentation fault (core dumped)
Weird. After 'make clean', I was no longer able to reproduce the failure; I then did a complete fresh checkout to verify on a pristine tree. I must have had some bad cruft lying around in my tree, and wonder what it was about your patch to expose that cruft?
At any rate, given that your patch does not fail after all, I will go ahead and push it. However, we still need a follow-up patch:
Quoted 2 lines
Hmm; missing a corresponding update to docs/formatdomain.html.in to document the new XML.
Signature · 2 lines
Eric Blake [email protected] +1-801-349-2682 Libvirt virtualization library http://libvirt.org