</attribute>
</optional>
<attribute name="name">
- <ref name="dnsName"/>
+ <choice>
+ <ref name="dnsName"/>
+ <ref name="ipAddr"/>
+ </choice>
</attribute>
<attribute name="port">
<ref name="unsignedInt"/>
#include "virerror.h"
#include "virutil.h"
#include "virfile.h"
+#include "virstring.h"
#include "viruuid.h"
#include "c-ctype.h"
#include "domain_nwfilter.h"
if (i) {
virBufferAddLit(opt, "\\;");
}
- if (disk->hosts[i].port) {
- virBufferAsprintf(opt, "%s\\:%s",
- disk->hosts[i].name,
- disk->hosts[i].port);
+
+ /* assume host containing : is ipv6 */
+ if (strchr(disk->hosts[i].name, ':')) {
+ virBufferEscape(opt, '\\', ":", "[%s]", disk->hosts[i].name);
} else {
virBufferAsprintf(opt, "%s", disk->hosts[i].name);
}
+ if (disk->hosts[i].port) {
+ virBufferAsprintf(opt, "\\:%s", disk->hosts[i].port);
+ }
}
}
static int qemuAddRBDHost(virDomainDiskDefPtr disk, char *hostport)
{
char *port;
+ size_t skip;
+ char **parts;
disk->nhosts++;
if (VIR_REALLOC_N(disk->hosts, disk->nhosts) < 0)
goto no_memory;
- port = strstr(hostport, "\\:");
+ if ((port = strchr(hostport, ']'))) {
+ /* ipv6, strip brackets */
+ hostport += 1;
+ skip = 3;
+ } else {
+ port = strstr(hostport, "\\:");
+ skip = 2;
+ }
+
if (port) {
*port = '\0';
- port += 2;
+ port += skip;
disk->hosts[disk->nhosts-1].port = strdup(port);
if (!disk->hosts[disk->nhosts-1].port)
goto no_memory;
if (!disk->hosts[disk->nhosts-1].port)
goto no_memory;
}
- disk->hosts[disk->nhosts-1].name = strdup(hostport);
+
+ parts = virStringSplit(hostport, "\\:", 0);
+ if (!parts)
+ goto no_memory;
+ disk->hosts[disk->nhosts-1].name = virStringJoin((const char **)parts, ":");
+ virStringFreeList(parts);
if (!disk->hosts[disk->nhosts-1].name)
goto no_memory;
DO_TEST("disk-drive-network-nbd");
DO_TEST("disk-drive-network-gluster");
DO_TEST("disk-drive-network-rbd");
+ DO_TEST("disk-drive-network-rbd-ipv6");
/* older format using CEPH_ARGS env var */
DO_TEST("disk-drive-network-rbd-ceph-env");
DO_TEST("disk-drive-network-sheepdog");
--- /dev/null
+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 -usb -drive \
+file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive \
+'file=rbd:pool/image:auth_supported=none:\
+mon_host=[\:\:1]\:6321\;example.org\:6789\;\
+[ffff\:1234\:567\:abc\:\:0f]\:6322\;\
+[2001\:db8\:\:ff00\:42\:8329]\:6322,\
+if=virtio,format=raw' -net none -serial none -parallel none
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>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' target='0' unit='0'/>
+ </disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='rbd' name='pool/image'>
+ <host name='::1' port='6321'/>
+ <host name='example.org' port='6789'/>
+ <host name='ffff:1234:567:abc::0f' port='6322'/>
+ <host name='2001:db8::ff00:42:8329' port='6322'/>
+ </source>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-network-rbd-auth",
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
+ DO_TEST("disk-drive-network-rbd-ipv6",
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
DO_TEST("disk-drive-no-boot",
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_BOOTINDEX);
DO_TEST("disk-usb", NONE);