On 2013年02月26日 01:44, Paolo Bonzini wrote:
QEMU 1.3 and newer support an alternative URI-based syntax to specify
the location of an NBD server. Libvirt can keep on using the old
syntax in general, but only the URI syntax supports IPv6 addresses.
The URI syntax also supports relative paths to Unix sockets. These
should never be used but aren't explicitly blocked either by the parser,
so support it just in case.
The URI syntax is intentionally compatible with Gluster's, and the
code can be reused.
Signed-off-by: Paolo Bonzini<pbonz...@redhat.com>
---
src/qemu/qemu_command.c | 97 +++++++++++++++-------
tests/qemuargv2xmltest.c | 2 +
...ml2argv-disk-drive-network-nbd-ipv6-export.args | 5 ++
...xml2argv-disk-drive-network-nbd-ipv6-export.xml | 33 ++++++++
.../qemuxml2argv-disk-drive-network-nbd-ipv6.args | 5 ++
.../qemuxml2argv-disk-drive-network-nbd-ipv6.xml | 33 ++++++++
tests/qemuxml2argvtest.c | 4 +
tests/qemuxml2xmltest.c | 2 +
8 files changed, 153 insertions(+), 28 deletions(-)
create mode 100644
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args
create mode 100644
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml
create mode 100644
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args
create mode 100644
tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 89cd065..733d3bf 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2050,35 +2050,36 @@ no_memory:
}
static int
-qemuParseGlusterString(virDomainDiskDefPtr def)
+qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
+ const char *scheme)
{
int ret = -1;
char *transp = NULL;
char *sock = NULL;
char *volimg = NULL;
- virURIPtr uri = NULL;
-
- if (!(uri = virURIParse(def->src))) {
- return -1;
- }
if (VIR_ALLOC(def->hosts)< 0)
goto no_memory;
- if (STREQ(uri->scheme, "gluster")) {
+ transp = strchr(uri->scheme, '+');
+ if (transp)
+ *transp++ = 0;
+
+ if (!STREQ(uri->scheme, scheme)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Invalid transport/scheme '%s'"), uri->scheme);
+ goto error;
+ }
How about uri->scheme is "gluster", and scheme is "nbd"? The error
doesn't reflect the truth then.
Except this and the coding style, all looks good.
Osier
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list