代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/libvirt 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From fb0de8df975557e74af01a0eee0d25c08981c02a Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Fri, 15 May 2020 08:50:31 +0200
Subject: [PATCH 15/18] testCompareXMLToArgv: Split out preparation and command
formatting
There are multiple steps of setting up the domain definition prior to
formatting the command line for the tests. Extract it to a separate
function so that it's self-contained and also will allow re-running the
command line formatting which will be necessary for QMP schema
validation tests.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
tests/qemuxml2argvtest.c | 158 +++++++++++++++++++++------------------
1 file changed, 86 insertions(+), 72 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 2153e44c5a..762d65f521 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -395,6 +395,90 @@ testCheckExclusiveFlags(int flags)
}
+static virCommandPtr
+testCompareXMLToArgvCreateArgs(virQEMUDriverPtr drv,
+ virDomainObjPtr vm,
+ const char *migrateURI,
+ struct testQemuInfo *info,
+ unsigned int flags)
+{
+ size_t i;
+
+ for (i = 0; i < vm->def->nhostdevs; i++) {
+ virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
+
+ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
+ hostdev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) {
+ hostdev->source.subsys.u.pci.backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
+ }
+ }
+
+ for (i = 0; i < vm->def->nfss; i++) {
+ virDomainFSDefPtr fs = vm->def->fss[i];
+ char *s;
+
+ if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS ||
+ QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock)
+ continue;
+
+ s = g_strdup_printf("/tmp/lib/domain--1-guest/fs%zu.vhost-fs.sock", i);
+ QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = s;
+ }
+
+ if (vm->def->vsock) {
+ virDomainVsockDefPtr vsock = vm->def->vsock;
+ qemuDomainVsockPrivatePtr vsockPriv =
+ (qemuDomainVsockPrivatePtr)vsock->privateData;
+
+ if (vsock->auto_cid == VIR_TRISTATE_BOOL_YES)
+ vsock->guest_cid = 42;
+
+ vsockPriv->vhostfd = 6789;
+ }
+
+ if (vm->def->tpm) {
+ switch (vm->def->tpm->type) {
+ case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+ VIR_FREE(vm->def->tpm->data.emulator.source.data.file.path);
+ vm->def->tpm->data.emulator.source.data.file.path = g_strdup("/dev/test");
+ vm->def->tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_FILE;
+ break;
+ case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+ case VIR_DOMAIN_TPM_TYPE_LAST:
+ break;
+ }
+ }
+
+ for (i = 0; i < vm->def->nvideos; i++) {
+ virDomainVideoDefPtr video = vm->def->videos[i];
+
+ if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
+ qemuDomainVideoPrivatePtr vpriv = QEMU_DOMAIN_VIDEO_PRIVATE(video);
+
+ vpriv->vhost_user_fd = 1729;
+ }
+ }
+
+ if (flags & FLAG_SLIRP_HELPER) {
+ for (i = 0; i < vm->def->nnets; i++) {
+ virDomainNetDefPtr net = vm->def->nets[i];
+
+ if (net->type == VIR_DOMAIN_NET_TYPE_USER &&
+ virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) {
+ qemuSlirpPtr slirp = qemuSlirpNew();
+ slirp->fd[0] = 42;
+ QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp = slirp;
+ }
+ }
+ }
+
+ return qemuProcessCreatePretendCmd(drv, vm, migrateURI,
+ (flags & FLAG_FIPS), false,
+ VIR_QEMU_PROCESS_START_COLD);
+}
+
+
static int
testCompareXMLToArgv(const void *data)
{
@@ -409,7 +493,6 @@ testCompareXMLToArgv(const void *data)
virConnectPtr conn;
char *log = NULL;
virCommandPtr cmd = NULL;
- size_t i;
qemuDomainObjPrivatePtr priv = NULL;
if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
@@ -486,77 +569,8 @@ testCompareXMLToArgv(const void *data)
VIR_FREE(log);
virResetLastError();
- for (i = 0; i < vm->def->nhostdevs; i++) {
- virDomainHostdevDefPtr hostdev = vm->def->hostdevs[i];
-
- if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
- hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
- hostdev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) {
- hostdev->source.subsys.u.pci.backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
- }
- }
-
- for (i = 0; i < vm->def->nfss; i++) {
- virDomainFSDefPtr fs = vm->def->fss[i];
- char *s;
-
- if (fs->fsdriver != VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS)
- continue;
-
- s = g_strdup_printf("/tmp/lib/domain--1-guest/fs%zu.vhost-fs.sock", i);
- QEMU_DOMAIN_FS_PRIVATE(fs)->vhostuser_fs_sock = s;
- }
-
- if (vm->def->vsock) {
- virDomainVsockDefPtr vsock = vm->def->vsock;
- qemuDomainVsockPrivatePtr vsockPriv =
- (qemuDomainVsockPrivatePtr)vsock->privateData;
-
- if (vsock->auto_cid == VIR_TRISTATE_BOOL_YES)
- vsock->guest_cid = 42;
-
- vsockPriv->vhostfd = 6789;
- }
-
- if (vm->def->tpm) {
- switch (vm->def->tpm->type) {
- case VIR_DOMAIN_TPM_TYPE_EMULATOR:
- VIR_FREE(vm->def->tpm->data.emulator.source.data.file.path);
- vm->def->tpm->data.emulator.source.data.file.path = g_strdup("/dev/test");
- vm->def->tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_FILE;
- break;
- case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
- case VIR_DOMAIN_TPM_TYPE_LAST:
- break;
- }
- }
-
- for (i = 0; i < vm->def->nvideos; i++) {
- virDomainVideoDefPtr video = vm->def->videos[i];
-
- if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
- qemuDomainVideoPrivatePtr vpriv = QEMU_DOMAIN_VIDEO_PRIVATE(video);
-
- vpriv->vhost_user_fd = 1729;
- }
- }
-
- if (flags & FLAG_SLIRP_HELPER) {
- for (i = 0; i < vm->def->nnets; i++) {
- virDomainNetDefPtr net = vm->def->nets[i];
-
- if (net->type == VIR_DOMAIN_NET_TYPE_USER &&
- virQEMUCapsGet(info->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) {
- qemuSlirpPtr slirp = qemuSlirpNew();
- slirp->fd[0] = 42;
- QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp = slirp;
- }
- }
- }
-
- if (!(cmd = qemuProcessCreatePretendCmd(&driver, vm, migrateURI,
- (flags & FLAG_FIPS), false,
- VIR_QEMU_PROCESS_START_COLD))) {
+ if (!(cmd = testCompareXMLToArgvCreateArgs(&driver, vm, migrateURI, info,
+ flags))) {
if (flags & FLAG_EXPECT_FAILURE)
goto ok;
goto cleanup;
--
2.23.0.windows.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。