From 7d2f942af91f244c501b337b5536c3292f31ca2a Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 15 Nov 2019 14:41:56 +0100 Subject: [PATCH] qemu: command: Build -blockdev-s for backing of pflash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As a first step we will build the blockdevs which will be supposed to back the pflash drives when moving away from -drive. This code is similar to the way we build the blockdevs for the disk, but skips the copy-on-read layer and doesn't implement any legacy approach. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrangé --- src/qemu/qemu_command.c | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c82d13483e..3505a9817d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9884,6 +9884,47 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd, } +static int +qemuBuildPflashBlockdevOne(virCommandPtr cmd, + virStorageSourcePtr src, + virQEMUCapsPtr qemuCaps) +{ + g_autoptr(qemuBlockStorageSourceChainData) data = NULL; + size_t i; + + if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(src, + qemuCaps))) + return -1; + + for (i = data->nsrcdata; i > 0; i--) { + if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, + data->srcdata[i - 1]) < 0) + return -1; + } + + return 0; +} + + +static int +qemuBuildPflashBlockdevCommandLine(virCommandPtr cmd, + qemuDomainObjPrivatePtr priv) +{ + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) + return 0; + + if (priv->pflash0 && + qemuBuildPflashBlockdevOne(cmd, priv->pflash0, priv->qemuCaps) < 0) + return -1; + + if (priv->pflash1 && + qemuBuildPflashBlockdevOne(cmd, priv->pflash1, priv->qemuCaps) < 0) + return -1; + + return 0; +} + + static virJSONValuePtr qemuBuildDBusVMStateInfoPropsInternal(const char *alias, const char *addr) @@ -10200,6 +10241,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildManagedPRCommandLine(cmd, def, priv) < 0) return NULL; + if (qemuBuildPflashBlockdevCommandLine(cmd, priv) < 0) + return NULL; + if (enableFips) virCommandAddArg(cmd, "-enable-fips"); -- GitLab