mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: support NBD with Unix sockets
This reuses the XML format that was introduced for Gluster. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
0aa9f522c4
commit
be2a15dd60
@ -1713,9 +1713,11 @@
|
|||||||
<td> only one </td>
|
<td> only one </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
In case of gluster, valid values for transport attribute are tcp, rdma
|
gluster supports "tcp", "rdma", "unix" as valid values for the
|
||||||
or unix. If nothing is specified, tcp is assumed. If transport is unix,
|
transport attribute. nbd supports "tcp" and "unix". Others only
|
||||||
socket attribute specifies path to unix socket.
|
support "tcp". If nothing is specified, "tcp" is assumed. If the
|
||||||
|
transport is "unix", the socket attribute specifies the path to an
|
||||||
|
AF_UNIX socket.
|
||||||
</dd>
|
</dd>
|
||||||
<dt><code>address</code></dt>
|
<dt><code>address</code></dt>
|
||||||
<dd>If present, the <code>address</code> element ties the disk
|
<dd>If present, the <code>address</code> element ties the disk
|
||||||
|
@ -2384,6 +2384,14 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
host = disk->src + strlen("nbd:");
|
host = disk->src + strlen("nbd:");
|
||||||
|
if (STRPREFIX(host, "unix:/")) {
|
||||||
|
src = strchr(host + strlen("unix:"), ':');
|
||||||
|
if (src)
|
||||||
|
*src++ = '\0';
|
||||||
|
|
||||||
|
h->transport = VIR_DOMAIN_DISK_PROTO_TRANS_UNIX;
|
||||||
|
h->socket = strdup(host + strlen("unix:"));
|
||||||
|
} else {
|
||||||
port = strchr(host, ':');
|
port = strchr(host, ':');
|
||||||
if (!port) {
|
if (!port) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
@ -2403,6 +2411,7 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
|
|||||||
h->port = strdup(port);
|
h->port = strdup(port);
|
||||||
if (!h->port)
|
if (!h->port)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
}
|
||||||
|
|
||||||
if (src && STRPREFIX(src, "exportname=")) {
|
if (src && STRPREFIX(src, "exportname=")) {
|
||||||
src = strdup(strchr(src, '=') + 1);
|
src = strdup(strchr(src, '=') + 1);
|
||||||
@ -2510,6 +2519,14 @@ qemuBuildNBDString(virDomainDiskDefPtr disk, virBufferPtr opt)
|
|||||||
disk->hosts->port ? disk->hosts->port :
|
disk->hosts->port ? disk->hosts->port :
|
||||||
QEMU_DEFAULT_NBD_PORT);
|
QEMU_DEFAULT_NBD_PORT);
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_DISK_PROTO_TRANS_UNIX:
|
||||||
|
if (!disk->hosts->socket) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("socket attribute required for unix transport"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
virBufferEscape(opt, ',', ",", "unix:%s", disk->hosts->socket);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
transp = virDomainDiskProtocolTransportTypeToString(disk->hosts->transport);
|
transp = virDomainDiskProtocolTransportTypeToString(disk->hosts->transport);
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
@ -186,6 +186,7 @@ mymain(void)
|
|||||||
DO_TEST("disk-drive-cache-unsafe");
|
DO_TEST("disk-drive-cache-unsafe");
|
||||||
DO_TEST("disk-drive-network-nbd");
|
DO_TEST("disk-drive-network-nbd");
|
||||||
DO_TEST("disk-drive-network-nbd-export");
|
DO_TEST("disk-drive-network-nbd-export");
|
||||||
|
DO_TEST("disk-drive-network-nbd-unix");
|
||||||
DO_TEST("disk-drive-network-gluster");
|
DO_TEST("disk-drive-network-gluster");
|
||||||
DO_TEST("disk-drive-network-rbd");
|
DO_TEST("disk-drive-network-rbd");
|
||||||
DO_TEST("disk-drive-network-rbd-ipv6");
|
DO_TEST("disk-drive-network-rbd-ipv6");
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
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=nbd:unix:/var/run/nbdsock:exportname=bar,if=virtio,format=raw \
|
||||||
|
-net none -serial none -parallel none
|
@ -0,0 +1,33 @@
|
|||||||
|
<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='nbd' name='bar'>
|
||||||
|
<host transport='unix' socket='/var/run/nbdsock'/>
|
||||||
|
</source>
|
||||||
|
<target dev='vda' bus='virtio'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -495,6 +495,8 @@ mymain(void)
|
|||||||
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
|
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
|
||||||
DO_TEST("disk-drive-network-nbd-export",
|
DO_TEST("disk-drive-network-nbd-export",
|
||||||
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
|
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
|
||||||
|
DO_TEST("disk-drive-network-nbd-unix",
|
||||||
|
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
|
||||||
DO_TEST("disk-drive-network-gluster",
|
DO_TEST("disk-drive-network-gluster",
|
||||||
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
|
QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_FORMAT);
|
||||||
DO_TEST("disk-drive-network-rbd",
|
DO_TEST("disk-drive-network-rbd",
|
||||||
|
@ -171,6 +171,7 @@ mymain(void)
|
|||||||
DO_TEST("disk-drive-cache-v1-none");
|
DO_TEST("disk-drive-cache-v1-none");
|
||||||
DO_TEST("disk-drive-network-nbd");
|
DO_TEST("disk-drive-network-nbd");
|
||||||
DO_TEST("disk-drive-network-nbd-export");
|
DO_TEST("disk-drive-network-nbd-export");
|
||||||
|
DO_TEST("disk-drive-network-nbd-unix");
|
||||||
DO_TEST("disk-scsi-device");
|
DO_TEST("disk-scsi-device");
|
||||||
DO_TEST("disk-scsi-vscsi");
|
DO_TEST("disk-scsi-vscsi");
|
||||||
DO_TEST("disk-scsi-virtio-scsi");
|
DO_TEST("disk-scsi-virtio-scsi");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user