[PATCH v6 04/11] nbd: Update qapi to support exporting multiple bitmaps
by Eric Blake
Since 'block-export-add' is new to 5.2, we can still tweak the
interface; there, allowing 'bitmaps':['str'] is nicer than
'bitmap':'str'. This wires up the qapi and qemu-nbd changes to permit
passing multiple bitmaps as distinct metadata contexts that the NBD
client may request, but the actual support for more than one will
require a further patch to the server.
Note that there are no changes made to the existing deprecated
'nbd-server-add' command; this required splitting the QAPI type
BlockExportOptionsNbd, which fortunately does not affect QMP
introspection.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
docs/system/deprecated.rst | 3 ++-
qapi/block-export.json | 41 +++++++++++++++++++++++++++-----------
blockdev-nbd.c | 6 +++++-
nbd/server.c | 19 ++++++++++++------
qemu-nbd.c | 18 ++++++++---------
5 files changed, 58 insertions(+), 29 deletions(-)
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 0ebce37a1919..32a0e620dbb9 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -257,7 +257,8 @@ the 'wait' field, which is only applicable to sockets in server mode
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Use the more generic commands ``block-export-add`` and ``block-export-del``
-instead.
+instead. As part of this deprecation, where ``nbd-server-add`` used a
+single ``bitmap``, the new ``block-export-add`` uses a list of ``bitmaps``.
Human Monitor Protocol (HMP) commands
-------------------------------------
diff --git a/qapi/block-export.json b/qapi/block-export.json
index 480c497690b0..c4125f4d2104 100644
--- a/qapi/block-export.json
+++ b/qapi/block-export.json
@@ -63,10 +63,10 @@
'*max-connections': 'uint32' } }
##
-# @BlockExportOptionsNbd:
+# @BlockExportOptionsNbdBase:
#
-# An NBD block export (options shared between nbd-server-add and the NBD branch
-# of block-export-add).
+# An NBD block export (common options shared between nbd-server-add and
+# the NBD branch of block-export-add).
#
# @name: Export name. If unspecified, the @device parameter is used as the
# export name. (Since 2.12)
@@ -74,15 +74,27 @@
# @description: Free-form description of the export, up to 4096 bytes.
# (Since 5.0)
#
-# @bitmap: Also export the dirty bitmap reachable from @device, so the
-# NBD client can use NBD_OPT_SET_META_CONTEXT with
-# "qemu:dirty-bitmap:NAME" to inspect the bitmap. (since 4.0)
-#
# Since: 5.0
##
+{ 'struct': 'BlockExportOptionsNbdBase',
+ 'data': { '*name': 'str', '*description': 'str' } }
+
+##
+# @BlockExportOptionsNbd:
+#
+# An NBD block export (distinct options used in the NBD branch of
+# block-export-add).
+#
+# @bitmaps: Also export each of the named dirty bitmaps reachable from
+# @device, so the NBD client can use NBD_OPT_SET_META_CONTEXT with
+# the metadata context name "qemu:dirty-bitmap:BITMAP" to inspect
+# each bitmap.
+#
+# Since: 5.2
+##
{ 'struct': 'BlockExportOptionsNbd',
- 'data': { '*name': 'str', '*description': 'str',
- '*bitmap': 'str' } }
+ 'base': 'BlockExportOptionsNbdBase',
+ 'data': { '*bitmaps': ['str'] } }
##
# @BlockExportOptionsVhostUserBlk:
@@ -106,19 +118,24 @@
##
# @NbdServerAddOptions:
#
-# An NBD block export.
+# An NBD block export, per legacy nbd-server-add command.
#
# @device: The device name or node name of the node to be exported
#
# @writable: Whether clients should be able to write to the device via the
# NBD connection (default false).
#
+# @bitmap: Also export a single dirty bitmap reachable from @device, so the
+# NBD client can use NBD_OPT_SET_META_CONTEXT with the metadata
+# context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap
+# (since 4.0).
+#
# Since: 5.0
##
{ 'struct': 'NbdServerAddOptions',
- 'base': 'BlockExportOptionsNbd',
+ 'base': 'BlockExportOptionsNbdBase',
'data': { 'device': 'str',
- '*writable': 'bool' } }
+ '*writable': 'bool', '*bitmap': 'str' } }
##
# @nbd-server-add:
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index cee9134b12eb..d1d41f635564 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -209,8 +209,12 @@ void qmp_nbd_server_add(NbdServerAddOptions *arg, Error **errp)
.has_writable = arg->has_writable,
.writable = arg->writable,
};
- QAPI_CLONE_MEMBERS(BlockExportOptionsNbd, &export_opts->u.nbd,
+ QAPI_CLONE_MEMBERS(BlockExportOptionsNbdBase, &export_opts->u.nbd,
qapi_NbdServerAddOptions_base(arg));
+ if (arg->has_bitmap) {
+ export_opts->u.nbd.has_bitmaps = true;
+ QAPI_LIST_ADD(export_opts->u.nbd.bitmaps, g_strdup(arg->bitmap));
+ }
/*
* nbd-server-add doesn't complain when a read-only device should be
diff --git a/nbd/server.c b/nbd/server.c
index 08b621f70a3a..8d01662b4511 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1474,6 +1474,7 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
uint64_t perm, shared_perm;
bool readonly = !exp_args->writable;
bool shared = !exp_args->writable;
+ strList *bitmaps;
int ret;
assert(exp_args->type == BLOCK_EXPORT_TYPE_NBD);
@@ -1533,12 +1534,18 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
}
exp->size = QEMU_ALIGN_DOWN(size, BDRV_SECTOR_SIZE);
- if (arg->bitmap) {
+ /* XXX Allow more than one bitmap */
+ if (arg->bitmaps && arg->bitmaps->next) {
+ error_setg(errp, "multiple bitmaps per export not supported yet");
+ return -EOPNOTSUPP;
+ }
+ for (bitmaps = arg->bitmaps; bitmaps; bitmaps = bitmaps->next) {
+ const char *bitmap = bitmaps->value;
BlockDriverState *bs = blk_bs(blk);
BdrvDirtyBitmap *bm = NULL;
while (bs) {
- bm = bdrv_find_dirty_bitmap(bs, arg->bitmap);
+ bm = bdrv_find_dirty_bitmap(bs, bitmap);
if (bm != NULL) {
break;
}
@@ -1548,7 +1555,7 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
if (bm == NULL) {
ret = -ENOENT;
- error_setg(errp, "Bitmap '%s' is not found", arg->bitmap);
+ error_setg(errp, "Bitmap '%s' is not found", bitmap);
goto fail;
}
@@ -1562,15 +1569,15 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
ret = -EINVAL;
error_setg(errp,
"Enabled bitmap '%s' incompatible with readonly export",
- arg->bitmap);
+ bitmap);
goto fail;
}
bdrv_dirty_bitmap_set_busy(bm, true);
exp->export_bitmap = bm;
- assert(strlen(arg->bitmap) <= BDRV_BITMAP_MAX_NAME_SIZE);
+ assert(strlen(bitmap) <= BDRV_BITMAP_MAX_NAME_SIZE);
exp->export_bitmap_context = g_strdup_printf("qemu:dirty-bitmap:%s",
- arg->bitmap);
+ bitmap);
assert(strlen(exp->export_bitmap_context) < NBD_MAX_STRING_SIZE);
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index a0701cdf369d..4b7825c44093 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -574,7 +574,7 @@ int main(int argc, char **argv)
QDict *options = NULL;
const char *export_name = NULL; /* defaults to "" later for server mode */
const char *export_description = NULL;
- const char *bitmap = NULL;
+ strList *bitmaps = NULL;
const char *tlscredsid = NULL;
bool imageOpts = false;
bool writethrough = true;
@@ -690,7 +690,7 @@ int main(int argc, char **argv)
flags &= ~BDRV_O_RDWR;
break;
case 'B':
- bitmap = optarg;
+ QAPI_LIST_ADD(bitmaps, g_strdup(optarg));
break;
case 'k':
sockpath = optarg;
@@ -786,7 +786,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
if (export_name || export_description || dev_offset ||
- device || disconnect || fmt || sn_id_or_name || bitmap ||
+ device || disconnect || fmt || sn_id_or_name || bitmaps ||
seen_aio || seen_discard || seen_cache) {
error_report("List mode is incompatible with per-device settings");
exit(EXIT_FAILURE);
@@ -1067,12 +1067,12 @@ int main(int argc, char **argv)
.has_writable = true,
.writable = !readonly,
.u.nbd = {
- .has_name = true,
- .name = g_strdup(export_name),
- .has_description = !!export_description,
- .description = g_strdup(export_description),
- .has_bitmap = !!bitmap,
- .bitmap = g_strdup(bitmap),
+ .has_name = true,
+ .name = g_strdup(export_name),
+ .has_description = !!export_description,
+ .description = g_strdup(export_description),
+ .has_bitmaps = !!bitmaps,
+ .bitmaps = bitmaps,
},
};
blk_exp_add(export_opts, &error_fatal);
--
2.29.0
4 years, 5 months
[libvirt PATCH 0/2] rpc: Fix virt-ssh-helper detection
by Andrea Bolognani
See patch 1 for details.
Andrea Bolognani (2):
rpc: Fix virt-ssh-helper detection
news: Mention virt-ssh-helper detection fix
NEWS.rst | 6 ++++++
src/rpc/virnetclient.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
--
2.26.2
4 years, 5 months
[PATCH v6 0/4] qemu: Support rbd namespace in rbd source name
by Han Han
Diffence from v5:
- conf: implement virStringSplit() to parse the src->path
- tests: Add the cases of path 'pool//image' to
disk-network-rbd-namespace test
- temporarily removed the patch of news
- tweak of version in docs
- rebase to the latest main branch
v5: https://www.redhat.com/archives/libvir-list/2020-September/msg00081.html
git repo: https://gitlab.com/hhan2/libvirt/-/commits/rbd-namespace-v6
Han Han (4):
qemu_capabilities: Add QEMU_CAPS_RBD_NAMESPACE
util: Add member ns to the storage source struct
conf: Support to parse rbd namespace from source name
qemu: Implement rbd namespace to the source name attribute
docs/formatdomain.rst | 16 ++++++
src/conf/domain_conf.c | 47 ++++++++++++++++--
src/qemu/qemu_block.c | 1 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_domain.c | 8 +++
src/util/virstoragefile.c | 2 +
src/util/virstoragefile.h | 1 +
.../caps_5.0.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 +
.../caps_5.0.0.riscv64.xml | 1 +
.../caps_5.0.0.x86_64.xml | 1 +
.../caps_5.1.0.x86_64.xml | 1 +
.../caps_5.2.0.x86_64.xml | 1 +
...k-network-rbd-namespace.x86_64-latest.args | 48 ++++++++++++++++++
.../disk-network-rbd-namespace.xml | 40 +++++++++++++++
tests/qemuxml2argvtest.c | 1 +
...sk-network-rbd-namespace.x86_64-latest.xml | 49 +++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
19 files changed, 219 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.xml
create mode 100644 tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml
--
2.26.2
4 years, 5 months
[libvirt PATCH v2 00/10] remote: introduce a custom netcat impl for ssh tunnelling
by Daniel P. Berrangé
We have long had a problem with use of netcat for ssh tunnelling because
there's no guarantee the UNIX socket path the client builds will match
the UNIX socket path the remote host uses. We don't even allow session
mode SSH tunnelling for this reason. We also can't easily auto-spawn
libvirtd in session mode.
With the introduction of modular daemons we also have potential for two
completely different UNIX socket paths even for system mode, and the
client can't know which to use.
The solution to all these problems is to introduce a custom netcat impl.
Instead passing the UNIX socket path, we pass the libvirt driver URI.
The custom netcat then decides which socket path to use based on the
remote build host environment.
We still have to support netcat for interoperability with legacy libvirt
versions, but we can default to the new virt-nc.
Daniel P. Berrangé (10):
rpc: merge logic for generating remote SSH shell script
remote: push logic for default netcat binary into common helper
remote: split off enums into separate source file
remote: split out function for parsing URI scheme
remote: parse the remote transport string earlier
remote: split out function for constructing socket path
remote: extract logic for determining daemon to connect to
remote: introduce virt-ssh-helper binary
rpc: switch order of args in virNetClientNewSSH
rpc: use new virt-ssh-helper binary for remote tunnelling
build-aux/syntax-check.mk | 2 +-
docs/uri.html.in | 24 +-
libvirt.spec.in | 2 +
po/POTFILES.in | 2 +
src/libvirt_remote.syms | 1 +
src/remote/Makefile.inc.am | 33 +++
src/remote/remote_driver.c | 323 ++++---------------------
src/remote/remote_sockets.c | 277 +++++++++++++++++++++
src/remote/remote_sockets.h | 70 ++++++
src/remote/remote_ssh_helper.c | 425 +++++++++++++++++++++++++++++++++
src/rpc/virnetclient.c | 166 ++++++++-----
src/rpc/virnetclient.h | 29 ++-
src/rpc/virnetsocket.c | 37 +--
src/rpc/virnetsocket.h | 4 +-
tests/virnetsockettest.c | 12 +-
15 files changed, 1035 insertions(+), 372 deletions(-)
create mode 100644 src/remote/remote_sockets.c
create mode 100644 src/remote/remote_sockets.h
create mode 100644 src/remote/remote_ssh_helper.c
--
2.26.2
4 years, 5 months
[PATCH 0/6] qemu: Fix cdrom as SCSI hostdev via -blockdev
by Peter Krempa
-drive detects whether a device is a cdrom automatically but we need to
use 'host_cdrom' when using blockdev explicitly. Fix the hostdev code
which was recently converted to -blockdev.
Warning:
I _don't_ have a box with a CDROM handy so this code is not tested in action!
Peter Krempa (6):
qemuProcessCreatePretendCmd: Split up preparation and command building
qemu: hostdev: Prepare definition bits in qemuDomainPrepareHostdev
qemu: Prepare hostdev data which depends on the host state separately
qemuxml2argvmock: Remove mocking of 'virSCSIDeviceGetSgName'
qemu: Detect whether a SCSI hostdev is a cdrom
qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>
src/qemu/qemu_command.c | 33 +-----
src/qemu/qemu_domain.c | 5 +
src/qemu/qemu_driver.c | 65 ++++++++++-
src/qemu/qemu_hotplug.c | 3 +
src/qemu/qemu_process.c | 103 +++++++++++++++---
src/qemu/qemu_process.h | 21 ++--
tests/qemuxml2argvdata/disk-cdrom.args | 4 +-
.../disk-cdrom.x86_64-2.12.0.args | 4 +-
.../disk-cdrom.x86_64-latest.args | 6 +-
tests/qemuxml2argvdata/disk-cdrom.xml | 5 +-
...hostdev-scsi-virtio-scsi.x86_64-2.8.0.args | 3 +
...hostdev-scsi-virtio-scsi.x86_64-4.1.0.args | 3 +
...ostdev-scsi-virtio-scsi.x86_64-latest.args | 4 +
.../hostdev-scsi-virtio-scsi.xml | 8 ++
tests/qemuxml2argvmock.c | 13 ---
tests/qemuxml2argvtest.c | 45 +++++++-
tests/qemuxml2xmloutdata/disk-cdrom.xml | 5 +-
.../hostdev-scsi-virtio-scsi.xml | 8 ++
18 files changed, 252 insertions(+), 86 deletions(-)
--
2.26.2
4 years, 5 months
[PATCH] qemuMonitorJSONCheckReply: Use g_autofree
by Yi Li
Eliminate cleanup code by using g_autofree.
Signed-off-by: Yi Li <yili(a)winhong.com>
---
src/qemu/qemu_monitor_json.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 26ac499fc5..f76b369191 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -392,10 +392,11 @@ qemuMonitorJSONCheckErrorFull(virJSONValuePtr cmd,
virJSONValuePtr reply,
bool report)
{
+ g_autofree char *cmdstr = virJSONValueToString(cmd, false);
+ g_autofree char *replystr = virJSONValueToString(reply, false);
+
if (virJSONValueObjectHasKey(reply, "error")) {
virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
- g_autofree char *cmdstr = virJSONValueToString(cmd, false);
- g_autofree char *replystr = virJSONValueToString(reply, false);
/* Log the full JSON formatted command & error */
VIR_DEBUG("unable to execute QEMU command %s: %s",
@@ -417,8 +418,6 @@ qemuMonitorJSONCheckErrorFull(virJSONValuePtr cmd,
return -1;
} else if (!virJSONValueObjectHasKey(reply, "return")) {
- g_autofree char *cmdstr = virJSONValueToString(cmd, false);
- g_autofree char *replystr = virJSONValueToString(reply, false);
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
NULLSTR(cmdstr), NULLSTR(replystr));
@@ -455,8 +454,8 @@ qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
data = virJSONValueObjectGet(reply, "return");
if (virJSONValueGetType(data) != type) {
- char *cmdstr = virJSONValueToString(cmd, false);
- char *retstr = virJSONValueToString(data, false);
+ g_autofree char *cmdstr = virJSONValueToString(cmd, false);
+ g_autofree char *retstr = virJSONValueToString(data, false);
VIR_DEBUG("Unexpected return type %d (expecting %d) for command %s: %s",
virJSONValueGetType(data), type, cmdstr, retstr);
@@ -464,8 +463,6 @@ qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
_("unexpected type returned by QEMU command '%s'"),
qemuMonitorJSONCommandName(cmd));
- VIR_FREE(cmdstr);
- VIR_FREE(retstr);
return -1;
}
--
2.25.3
4 years, 5 months
[PATCH] docs: page.xsl: Improve generation of paragraph anchor links
by Peter Krempa
Use the 'parent' axis to check whether the parent is a div with
class='section' rather than looking for 'toc-backref' anchor to see
whether to generate one of the headerlink alternatives. Both hare
docutils-specific thus apply to docs generated from RST documents.
This adds the links for pages generated from RST documents which don't
have a table of contents (and thus lack the 'toc-backref' anchors) and
thus fixes pages such as hacking.html and news.html to have reasonable
links which can be shared.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
Note that whether or not to add table of contents to hacking.rst is out
of scope of this patch.
docs/page.xsl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/page.xsl b/docs/page.xsl
index 36168305fa..07bfc52a4c 100644
--- a/docs/page.xsl
+++ b/docs/page.xsl
@@ -196,7 +196,7 @@
<xsl:if test="./html:a/@id">
<a class="headerlink" href="#{html:a/@id}" title="Permalink to this headline">¶</a>
</xsl:if>
- <xsl:if test="./html:a[@class='toc-backref']">
+ <xsl:if test="parent::html:div[@class='section']">
<a class="headerlink" href="#{../@id}" title="Permalink to this headline">¶</a>
</xsl:if>
</xsl:element>
--
2.26.2
4 years, 5 months
[PATCH 0/9] several small cleanups in virpci.c et. al.
by Laine Stump
These started with a couple small cleanups to functions I was going to
change the API for, but then I decided not to change the API, and just
didn't want to waste the effort spent cleaning them up.
Laine Stump (9):
util: simplify virHostdevPCISysfsPath()
util: simplify virPCIFile() and its callers
util: simplify virPCIDriverDir() and its callers
util: simplify virPCIProbeStubDriver()
util: avoid manual VIR_FREE of a g_autofree pointer in virPCIGetName()
util: use more g_autofree in virpci.c
util: remove unneeded cleanup:/ret in virpci.c
util: don't use virPCIGetSysfsFile()
util: remove unused function virPCIGetSysfsFile()
src/hypervisor/virhostdev.c | 10 +--
src/libvirt_private.syms | 1 -
src/util/virnetdev.c | 6 +-
src/util/virpci.c | 146 ++++++++++++------------------------
src/util/virpci.h | 4 -
5 files changed, 53 insertions(+), 114 deletions(-)
--
2.26.2
4 years, 5 months
[libvirt PATCH] meson: remove non-pkg-config fallback for devmapper
by Daniel P. Berrangé
The fallback for distros which lack pkg-config support for devmapper
references an undefined variable "tmp". It appears non of our supported
build platforms are triggering this bug and so the fallback code can be
removed entirely rather than fixed.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
meson.build | 7 -------
1 file changed, 7 deletions(-)
diff --git a/meson.build b/meson.build
index a17d759702..c3ba34bbe0 100644
--- a/meson.build
+++ b/meson.build
@@ -1020,13 +1020,6 @@ endif
devmapper_version = '1.0.0'
devmapper_dep = dependency('devmapper', version: '>=' + devmapper_version, required: false)
-if not devmapper_dep.found()
- # devmapper is missing pkg-config files in ubuntu, suse, etc
- devmapper_dep = cc.find_library('devmapper', required: false)
- if devmapper_dep.found() and not cc.has_function('dm_task_run', dependencies: tmp)
- devmapper_dep = dependency('', required: false)
- endif
-endif
if devmapper_dep.found()
conf.set('WITH_DEVMAPPER', 1)
endif
--
2.25.4
4 years, 5 months
[PATCH] qemu: Add test cases for 'host_cdrom' blockdev backend via <disk>
by Peter Krempa
Simulate that the device is a cdrom when the path equals to /dev/cdrom
to provide testing for the 'host_cdrom' backend.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
I've already posted this before but I mistakenly identified is as wrong
and self-NACKed it, but we don't really have a test for a <disk
type=cdrom> backed by a host device, so this patch makes sense.
tests/qemuxml2argvdata/disk-cdrom.args | 4 ++--
tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args | 4 ++--
tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args | 6 +++---
tests/qemuxml2argvdata/disk-cdrom.xml | 5 +++--
tests/qemuxml2argvtest.c | 11 +++++++++++
tests/qemuxml2xmloutdata/disk-cdrom.xml | 5 +++--
6 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/tests/qemuxml2argvdata/disk-cdrom.args b/tests/qemuxml2argvdata/disk-cdrom.args
index cbac368129..e506a4befe 100644
--- a/tests/qemuxml2argvdata/disk-cdrom.args
+++ b/tests/qemuxml2argvdata/disk-cdrom.args
@@ -25,8 +25,8 @@ server,nowait \
-no-shutdown \
-no-acpi \
-usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-0-0,readonly=on \
+-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-drive file=/root/boot.iso,format=raw,if=none,id=drive-ide0-0-1,readonly=on \
-device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
-drive if=none,id=drive-ide0-1-0,readonly=on \
diff --git a/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args b/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args
index 2440acc78a..0621746a3b 100644
--- a/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args
+++ b/tests/qemuxml2argvdata/disk-cdrom.x86_64-2.12.0.args
@@ -27,8 +27,8 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-no-acpi \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
+-drive file=/dev/cdrom,format=raw,if=none,id=drive-ide0-0-0,readonly=on \
+-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-drive file=/root/boot.iso,format=raw,if=none,id=drive-ide0-0-1,readonly=on \
-device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
-drive if=none,id=drive-ide0-1-0,readonly=on \
diff --git a/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args b/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args
index 0d375ffd1c..beac75ec1d 100644
--- a/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-cdrom.x86_64-latest.args
@@ -29,11 +29,11 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-no-acpi \
-boot strict=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
--blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1",\
+-blockdev '{"driver":"host_cdrom","filename":"/dev/cdrom",\
"node-name":"libvirt-4-storage","auto-read-only":true,"discard":"unmap"}' \
--blockdev '{"node-name":"libvirt-4-format","read-only":false,"driver":"raw",\
+-blockdev '{"node-name":"libvirt-4-format","read-only":true,"driver":"raw",\
"file":"libvirt-4-storage"}' \
--device ide-hd,bus=ide.0,unit=0,drive=libvirt-4-format,id=ide0-0-0,bootindex=1 \
+-device ide-cd,bus=ide.0,unit=0,drive=libvirt-4-format,id=ide0-0-0 \
-blockdev '{"driver":"file","filename":"/root/boot.iso",\
"node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-3-format","read-only":true,"driver":"raw",\
diff --git a/tests/qemuxml2argvdata/disk-cdrom.xml b/tests/qemuxml2argvdata/disk-cdrom.xml
index b051b16642..54d2927ac3 100644
--- a/tests/qemuxml2argvdata/disk-cdrom.xml
+++ b/tests/qemuxml2argvdata/disk-cdrom.xml
@@ -14,10 +14,11 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-i386</emulator>
- <disk type='block' device='disk'>
+ <disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
- <source dev='/dev/HostVG/QEMUGuest1'/>
+ <source dev='/dev/cdrom'/>
<target dev='hda' bus='ide'/>
+ <readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c5a0095e0d..ef8a871a19 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -407,6 +407,17 @@ testCompareXMLToArgvCreateArgs(virQEMUDriverPtr drv,
VIR_QEMU_PROCESS_START_COLD) < 0)
return NULL;
+ for (i = 0; i < vm->def->ndisks; i++) {
+ virDomainDiskDefPtr disk = vm->def->disks[i];
+
+ /* host cdrom requires special treatment in qemu, mock it */
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
+ disk->src->format == VIR_STORAGE_FILE_RAW &&
+ virStorageSourceIsBlockLocal(disk->src) &&
+ STREQ(disk->src->path, "/dev/cdrom"))
+ disk->src->hostcdrom = true;
+ }
+
for (i = 0; i < vm->def->nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
diff --git a/tests/qemuxml2xmloutdata/disk-cdrom.xml b/tests/qemuxml2xmloutdata/disk-cdrom.xml
index 3e6475c276..3a8c34761d 100644
--- a/tests/qemuxml2xmloutdata/disk-cdrom.xml
+++ b/tests/qemuxml2xmloutdata/disk-cdrom.xml
@@ -14,10 +14,11 @@
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-i386</emulator>
- <disk type='block' device='disk'>
+ <disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
- <source dev='/dev/HostVG/QEMUGuest1'/>
+ <source dev='/dev/cdrom'/>
<target dev='hda' bus='ide'/>
+ <readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
--
2.26.2
4 years, 5 months