From nobody Thu May 15 19:09:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1504133499786824.5493962162203; Wed, 30 Aug 2017 15:51:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5E3B81DE2; Wed, 30 Aug 2017 22:51:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C71B8F371; Wed, 30 Aug 2017 22:51:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 29C4B1806107; Wed, 30 Aug 2017 22:51:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7UMkLa2022323 for ; Wed, 30 Aug 2017 18:46:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 18C817093F; Wed, 30 Aug 2017 22:46:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-88.phx2.redhat.com [10.3.116.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id C388377709; Wed, 30 Aug 2017 22:46:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A5E3B81DE2 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Wed, 30 Aug 2017 18:46:06 -0400 Message-Id: <20170830224613.24738-7-jferlan@redhat.com> In-Reply-To: <20170830224613.24738-1-jferlan@redhat.com> References: <20170830224613.24738-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: ashish.mittal@veritas.com Subject: [libvirt] [PATCH v6 06/13] qemu: Add qemu command line generation for a VxHS block device X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 30 Aug 2017 22:51:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Ashish Mittal The VxHS block device will only use the newer formatting options and avoid the legacy URI syntax. An excerpt for a sample QEMU command line is: -drive file.driver=3Dvxhs,file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4= dc251,\ file.server.0.type=3Dtcp,file.server.0.host=3D192.168.0.1,\ file.server.0.port=3D9999,format=3Draw,if=3Dnone,id=3Ddrive-virtio-disk0= ,cache=3Dnone \ -device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk0,\ id=3Dvirtio-disk0 Update qemuxml2argvtest with a simple test. Signed-off-by: Ashish Mittal Signed-off-by: John Ferlan --- This combines the rest of v5 patch1 (the src/qemu/qemu_*.c files) and patch2. The changes are: * Remove qemuBuildVxHSDriveJSONHost and replace with call to qemuBlockStorageSourceBuildHostsJSONSocketAddress * Add QEMU_CAPS_VXHS to qemuBlockStorageSourceGetVxHSProps * Remove the unnecessary "ret =3D NULL;" from error path as when an error is returned, ret will be NULL. * Add @qemuCaps to qemuBlockStorageSourceGetBackendProps since it's going to be necessary to check the capabilities for VxHS. * Altered the output *.args file to have the "file.server.0" as well as adding "file.server.0.type=3Dtcp". * Altered the qemuxml2argvtest to pass the QEMU_CAPS_VXHS bit/flag. src/qemu/qemu_block.c | 48 ++++++++++++++++++= +++- src/qemu/qemu_block.h | 3 +- src/qemu/qemu_command.c | 12 +++++- src/qemu/qemu_parse_command.c | 16 +++++++- .../qemuxml2argv-disk-drive-network-vxhs.args | 27 ++++++++++++ tests/qemuxml2argvtest.c | 1 + 6 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-= vxhs.args diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index d07269f..cb765ab 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -482,6 +482,45 @@ qemuBlockStorageSourceGetGlusterProps(virStorageSource= Ptr src) } =20 =20 +static virJSONValuePtr +qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr src, + virQEMUCapsPtr qemuCaps) +{ + const char *protocol =3D virStorageNetProtocolTypeToString(src->protoc= ol); + virJSONValuePtr server =3D NULL; + virJSONValuePtr ret =3D NULL; + + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VXHS)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VxHS protocol is not supported with this QEMU bi= nary")); + return NULL; + } + + if (src->nhosts !=3D 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("VxHS protocol accepts only one host")); + return NULL; + } + + if (!(server =3D qemuBlockStorageSourceBuildHostsJSONSocketAddress(src= , true))) + return NULL; + + /* VxHS disk specification example: + * { driver:"vxhs", + * vdisk-id:"eb90327c-8302-4725-4e85ed4dc251", + * server:[{type:"tcp", host:"1.2.3.4", port:9999}]} + */ + if (virJSONValueObjectCreate(&ret, + "s:driver", protocol, + "s:vdisk-id", src->path, + "a:server", server, NULL) < 0) + virJSONValueFree(server); + + return ret; +} + + /** * qemuBlockStorageSourceGetBackendProps: * @src: disk source @@ -490,7 +529,8 @@ qemuBlockStorageSourceGetGlusterProps(virStorageSourceP= tr src) * storage source. Returns NULL on error and reports an appropriate error = message. */ virJSONValuePtr -qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src) +qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src, + virQEMUCapsPtr qemuCaps) { int actualType =3D virStorageSourceGetActualType(src); virJSONValuePtr fileprops =3D NULL; @@ -512,6 +552,11 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource= Ptr src) goto cleanup; break; =20 + case VIR_STORAGE_NET_PROTOCOL_VXHS: + if (!(fileprops =3D qemuBlockStorageSourceGetVxHSProps(src, qe= muCaps))) + goto cleanup; + break; + case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_RBD: case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG: @@ -522,7 +567,6 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourceP= tr src) case VIR_STORAGE_NET_PROTOCOL_FTPS: case VIR_STORAGE_NET_PROTOCOL_TFTP: case VIR_STORAGE_NET_PROTOCOL_SSH: - case VIR_STORAGE_NET_PROTOCOL_VXHS: case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_LAST: break; diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index f0a2c9a..90f78e3 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -54,6 +54,7 @@ virHashTablePtr qemuBlockGetNodeData(virJSONValuePtr data); =20 virJSONValuePtr -qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src); +qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src, + virQEMUCapsPtr qemuCaps); =20 #endif /* __QEMU_BLOCK_H__ */ diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b7a896e..3205a59 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -991,12 +991,16 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src, ret =3D virBufferContentAndReset(&buf); break; =20 + case VIR_STORAGE_NET_PROTOCOL_VXHS: + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("VxHS protocol does not support URI syntax")); + goto cleanup; + case VIR_STORAGE_NET_PROTOCOL_SSH: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'ssh' protocol is not yet supported")); goto cleanup; =20 - case VIR_STORAGE_NET_PROTOCOL_VXHS: case VIR_STORAGE_NET_PROTOCOL_LAST: case VIR_STORAGE_NET_PROTOCOL_NONE: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1326,6 +1330,10 @@ qemuDiskSourceNeedsProps(virStorageSourcePtr src) src->nhosts > 1) return true; =20 + if (actualType =3D=3D VIR_STORAGE_TYPE_NETWORK && + src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_VXHS) + return true; + return false; } =20 @@ -1345,7 +1353,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk, int ret =3D -1; =20 if (qemuDiskSourceNeedsProps(disk->src) && - !(srcprops =3D qemuBlockStorageSourceGetBackendProps(disk->src))) + !(srcprops =3D qemuBlockStorageSourceGetBackendProps(disk->src, qe= muCaps))) goto cleanup; =20 if (!srcprops && diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 9190a37..6286c2e 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -736,6 +736,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, if (VIR_STRDUP(def->src->path, vdi) < 0) goto error; } + } else if (STRPREFIX(def->src->path, "vxhs:")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("VxHS protocol does not support URI s= yntax '%s'"), + def->src->path); + goto error; } else { def->src->type =3D VIR_STORAGE_TYPE_FILE; } @@ -1944,6 +1949,10 @@ qemuParseCommandLine(virCapsPtr caps, disk->src->type =3D VIR_STORAGE_TYPE_NETWORK; disk->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_SHEEPDOG; val +=3D strlen("sheepdog:"); + } else if (STRPREFIX(val, "vxhs:")) { + disk->src->type =3D VIR_STORAGE_TYPE_NETWORK; + disk->src->protocol =3D VIR_STORAGE_NET_PROTOCOL_VXHS; + val +=3D strlen("vxhs:"); } else { disk->src->type =3D VIR_STORAGE_TYPE_FILE; } @@ -2020,13 +2029,18 @@ qemuParseCommandLine(virCapsPtr caps, goto error; =20 break; + case VIR_STORAGE_NET_PROTOCOL_VXHS: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("VxHS protocol does not support URI " + "syntax '%s'"), disk->src->path); + goto error; + break; case VIR_STORAGE_NET_PROTOCOL_HTTP: case VIR_STORAGE_NET_PROTOCOL_HTTPS: case VIR_STORAGE_NET_PROTOCOL_FTP: case VIR_STORAGE_NET_PROTOCOL_FTPS: case VIR_STORAGE_NET_PROTOCOL_TFTP: case VIR_STORAGE_NET_PROTOCOL_SSH: - case VIR_STORAGE_NET_PROTOCOL_VXHS: case VIR_STORAGE_NET_PROTOCOL_LAST: case VIR_STORAGE_NET_PROTOCOL_NONE: /* ignored for now */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-vxhs.ar= gs b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-vxhs.args new file mode 100644 index 0000000..86da1af --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-vxhs.args @@ -0,0 +1,27 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu qemu32 \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest1/moni= tor.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dreadline \ +-no-acpi \ +-boot c \ +-usb \ +-drive file.driver=3Dvxhs,file.vdisk-id=3Deb90327c-8302-4725-9e1b-4e85ed4d= c251,\ +file.server.0.type=3Dtcp,file.server.0.host=3D192.168.0.1,file.server.0.po= rt=3D9999,\ +format=3Draw,if=3Dnone,id=3Ddrive-virtio-disk0,cache=3Dnone \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,drive=3Ddrive-virtio-disk0,\ +id=3Dvirtio-disk0 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 18f06e5..b92ded8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -931,6 +931,7 @@ mymain(void) # endif DO_TEST("disk-drive-network-rbd-ipv6", NONE); DO_TEST_FAILURE("disk-drive-network-rbd-no-colon", NONE); + DO_TEST("disk-drive-network-vxhs", QEMU_CAPS_VXHS); DO_TEST("disk-drive-no-boot", QEMU_CAPS_BOOTINDEX); DO_TEST_PARSE_ERROR("disk-device-lun-type-invalid", --=20 2.9.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list