提交 11d13ad8 编写于 作者: P Peter Krempa

qemu: domain: Introduce helper to convert <loader> into virStorageSource

Add a helper which will covert the PFLASH code file and variable file
into the virStorageSource objects stored in private data so that we can
use them with -blockdev while keeping the infrastructure to determine
the path to the loaders intact.

This is a temporary solution until we will want to do snapshots of the
pflash where we will be forced do track the full backing chain in the
XML.

In the meanwhile just convert it partially so that we can stop using
-drive.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 07675b01
......@@ -15609,3 +15609,61 @@ qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm)
return 0;
}
/**
* qemuDomainInitializePflashStorageSource:
*
* This helper converts the specification of the source of the 'loader' in case
* PFLASH is required to virStorageSources in case QEMU_CAPS_BLOCKDEV is present.
*
* This helper is used in the intermediate state when we don't support full
* backing chains for pflash drives in the XML.
*
* The nodenames used here have a different prefix to allow for a later
* conversion. The prefixes are 'libvirt-pflash0-storage',
* 'libvirt-pflash0-format' for pflash0 and 'libvirt-pflash1-storage' and
* 'libvirt-pflash1-format' for pflash1.
*/
int
qemuDomainInitializePflashStorageSource(virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr def = vm->def;
g_autoptr(virStorageSource) pflash0 = NULL;
g_autoptr(virStorageSource) pflash1 = NULL;
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
return 0;
if (!def->os.loader ||
def->os.loader->type != VIR_DOMAIN_LOADER_TYPE_PFLASH)
return 0;
if (!(pflash0 = virStorageSourceNew()))
return -1;
pflash0->type = VIR_STORAGE_TYPE_FILE;
pflash0->format = VIR_STORAGE_FILE_RAW;
pflash0->path = g_strdup(def->os.loader->path);
pflash0->readonly = def->os.loader->readonly;
pflash0->nodeformat = g_strdup("libvirt-pflash0-format");
pflash0->nodestorage = g_strdup("libvirt-pflash0-storage");
if (def->os.loader->nvram) {
if (!(pflash1 = virStorageSourceNew()))
return -1;
pflash1->type = VIR_STORAGE_TYPE_FILE;
pflash1->format = VIR_STORAGE_FILE_RAW;
pflash1->path = g_strdup(def->os.loader->nvram);
pflash1->readonly = false;
pflash1->nodeformat = g_strdup("libvirt-pflash1-format");
pflash1->nodestorage = g_strdup("libvirt-pflash1-storage");
}
priv->pflash0 = g_steal_pointer(&pflash0);
priv->pflash1 = g_steal_pointer(&pflash1);
return 0;
}
......@@ -1235,3 +1235,6 @@ qemuDomainSupportsCheckpointsBlockjobs(virDomainObjPtr vm)
int
qemuDomainMakeCPUMigratable(virCPUDefPtr cpu);
int
qemuDomainInitializePflashStorageSource(virDomainObjPtr vm);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册