mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 02:25:18 +00:00
qemu: block: Use proper type for servers for VxHS disks
Original implementation used 'SocketAddress' equivalent from qemu for the disk server field, while qemu documentation specifies 'InetSocketAddress'. The backing store parser uses the correct parsing function but the formatter used the incorrect one (and also with the legacy mode enabled which was wrong).
This commit is contained in:
parent
1f467d1ab1
commit
bd37213786
@ -501,6 +501,40 @@ qemuBlockStorageSourceBuildHostsJSONSocketAddress(virStorageSourcePtr src,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuBlockStorageSourceBuildJSONInetSocketAddress
|
||||
* @host: the virStorageNetHostDefPtr definition to build
|
||||
*
|
||||
* Formats @hosts into a json object conforming to the 'InetSocketAddress' type
|
||||
* in qemu.
|
||||
*
|
||||
* Returns a virJSONValuePtr for a single server.
|
||||
*/
|
||||
static virJSONValuePtr
|
||||
qemuBlockStorageSourceBuildJSONInetSocketAddress(virStorageNetHostDefPtr host)
|
||||
{
|
||||
virJSONValuePtr ret = NULL;
|
||||
char *port = NULL;
|
||||
|
||||
if (host->transport != VIR_STORAGE_NET_HOST_TRANS_TCP) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("only TCP protocol can be converted to InetSocketAddress"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (virAsprintf(&port, "%u", host->port) < 0)
|
||||
return NULL;
|
||||
|
||||
ignore_value(virJSONValueObjectCreate(&ret,
|
||||
"s:host", host->name,
|
||||
"s:port", port,
|
||||
NULL));
|
||||
|
||||
VIR_FREE(port);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static virJSONValuePtr
|
||||
qemuBlockStorageSourceGetGlusterProps(virStorageSourcePtr src)
|
||||
{
|
||||
@ -540,7 +574,7 @@ qemuBlockStorageSourceGetVxHSProps(virStorageSourcePtr src)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(server = qemuBlockStorageSourceBuildJSONSocketAddress(src->hosts, true)))
|
||||
if (!(server = qemuBlockStorageSourceBuildJSONInetSocketAddress(&src->hosts[0])))
|
||||
return NULL;
|
||||
|
||||
/* VxHS disk specification example:
|
||||
|
@ -23,7 +23,7 @@ server,nowait \
|
||||
-object tls-creds-x509,id=objvirtio-disk0_tls0,dir=/etc/pki/libvirt-vxhs,\
|
||||
endpoint=client,verify-peer=yes \
|
||||
-drive file.driver=vxhs,file.tls-creds=objvirtio-disk0_tls0,\
|
||||
file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc251,file.server.type=tcp,\
|
||||
file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc251,\
|
||||
file.server.host=192.168.0.1,file.server.port=9999,format=raw,if=none,\
|
||||
id=drive-virtio-disk0,cache=none \
|
||||
-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
|
||||
@ -31,13 +31,13 @@ id=virtio-disk0 \
|
||||
-object tls-creds-x509,id=objvirtio-disk1_tls0,dir=/etc/pki/libvirt-vxhs,\
|
||||
endpoint=client,verify-peer=yes \
|
||||
-drive file.driver=vxhs,file.tls-creds=objvirtio-disk1_tls0,\
|
||||
file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc252,file.server.type=tcp,\
|
||||
file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc252,\
|
||||
file.server.host=192.168.0.2,file.server.port=9999,format=raw,if=none,\
|
||||
id=drive-virtio-disk1,cache=none \
|
||||
-device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk1,\
|
||||
id=virtio-disk1 \
|
||||
-drive file.driver=vxhs,file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc253,\
|
||||
file.server.type=tcp,file.server.host=192.168.0.3,file.server.port=9999,\
|
||||
format=raw,if=none,id=drive-virtio-disk2,cache=none \
|
||||
file.server.host=192.168.0.3,file.server.port=9999,format=raw,if=none,\
|
||||
id=drive-virtio-disk2,cache=none \
|
||||
-device virtio-blk-pci,bus=pci.0,addr=0x6,drive=drive-virtio-disk2,\
|
||||
id=virtio-disk2
|
||||
|
@ -21,7 +21,7 @@ server,nowait \
|
||||
-boot c \
|
||||
-usb \
|
||||
-drive file.driver=vxhs,file.vdisk-id=eb90327c-8302-4725-9e1b-4e85ed4dc251,\
|
||||
file.server.type=tcp,file.server.host=192.168.0.1,file.server.port=9999,\
|
||||
format=raw,if=none,id=drive-virtio-disk0,cache=none \
|
||||
file.server.host=192.168.0.1,file.server.port=9999,format=raw,if=none,\
|
||||
id=drive-virtio-disk0,cache=none \
|
||||
-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\
|
||||
id=virtio-disk0
|
||||
|
@ -1601,8 +1601,7 @@ mymain(void)
|
||||
"</source>\n");
|
||||
TEST_BACKING_PARSE("json:{\"file\":{\"driver\":\"vxhs\","
|
||||
"\"vdisk-id\":\"c6718f6b-0401-441d-a8c3-1f0064d75ee0\","
|
||||
"\"server\": { \"type\":\"tcp\","
|
||||
"\"host\":\"example.com\","
|
||||
"\"server\": { \"host\":\"example.com\","
|
||||
"\"port\":\"9999\""
|
||||
"}"
|
||||
"}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user