1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

qemu: Update to new design of 'block-export-add'

qemu decided to modify the arguments of 'block-export-add' to include an
array of bitmaps rather than a single bitmap.

Since we've added the code prior to qemu setting the interface in stone
and thus it will be changed incompatibly and we already have tests for
the new interface we need to update the code and qemu capabilities data
at the same time.

Use a array of bitmaps as the 'bitmaps' argument instead of 'bitmap' and
bump qemu capabilities for the upcoming 5.2.0 release to
v5.1.0-2827-g2c6605389c

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Peter Krempa 2020-10-26 13:06:17 +01:00
parent e9c1b5c92e
commit 1c2314b938
5 changed files with 2772 additions and 2437 deletions

View File

@ -3369,20 +3369,30 @@ virJSONValuePtr
qemuBlockExportGetNBDProps(const char *nodename,
const char *exportname,
bool writable,
const char *bitmap)
const char **bitmaps)
{
g_autofree char *exportid = NULL;
g_autoptr(virJSONValue) bitmapsarr = NULL;
virJSONValuePtr ret = NULL;
exportid = g_strdup_printf("libvirt-nbd-%s", nodename);
if (bitmaps && *bitmaps) {
bitmapsarr = virJSONValueNewArray();
while (*bitmaps) {
if (virJSONValueArrayAppendString(bitmapsarr, *(bitmaps++)) < 0)
return NULL;
}
}
if (virJSONValueObjectCreate(&ret,
"s:type", "nbd",
"s:id", exportid,
"s:node-name", nodename,
"b:writable", writable,
"s:name", exportname,
"S:bitmap", bitmap,
"A:bitmaps", &bitmapsarr,
NULL) < 0)
return NULL;
@ -3418,11 +3428,12 @@ qemuBlockExportAddNBD(virDomainObjPtr vm,
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_EXPORT_ADD)) {
g_autoptr(virJSONValue) nbdprops = NULL;
const char *bitmaps[2] = { bitmap, NULL };
if (!(nbdprops = qemuBlockExportGetNBDProps(src->nodeformat,
exportname,
writable,
bitmap)))
bitmaps)))
return -1;
return qemuMonitorBlockExportAdd(priv->mon, &nbdprops);

View File

@ -281,7 +281,7 @@ virJSONValuePtr
qemuBlockExportGetNBDProps(const char *nodename,
const char *exportname,
bool writable,
const char *bitmap);
const char **bitmaps);
int

File diff suppressed because it is too large Load Diff

View File

@ -250,7 +250,7 @@
<version>5001050</version>
<kvmVersion>0</kvmVersion>
<microcodeVersion>43100243</microcodeVersion>
<package>v5.1.0-2207-g96292515c0</package>
<package>v5.1.0-2827-g2c6605389c</package>
<arch>x86_64</arch>
<hostCPU type='kvm' model='base' migratability='yes'>
<property name='vmx-entry-load-rtit-ctl' type='boolean' value='false'/>

View File

@ -3052,11 +3052,12 @@ testQemuMonitorJSONBlockExportAdd(const void *opaque)
const testGenericData *data = opaque;
g_autoptr(qemuMonitorTest) test = NULL;
g_autoptr(virJSONValue) nbddata = NULL;
const char *bitmaps[] = { "bitmap1", "bitmap2", NULL };
if (!(test = qemuMonitorTestNewSchema(data->xmlopt, data->schema)))
return -1;
if (!(nbddata = qemuBlockExportGetNBDProps("nodename", "exportname", true, "bitmapname")))
if (!(nbddata = qemuBlockExportGetNBDProps("nodename", "exportname", true, bitmaps)))
return -1;
if (qemuMonitorTestAddItem(test, "block-export-add", "{\"return\":{}}") < 0)