You need to sign in or sign up before continuing.
提交 9f51c1c7 编写于 作者: P Pavel Hrdina

graphics: generate fake ports also for tests

Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 446aebbc
...@@ -7060,18 +7060,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, ...@@ -7060,18 +7060,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->mac = mac; net->mac = mac;
} }
/* do fake auto-alloc of graphics ports, if such config is used */
for (i = 0; i < vm->def->ngraphics; ++i) {
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
if (qemuProcessVNCAllocatePorts(driver, graphics, false) < 0)
goto cleanup;
} else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, false) < 0)
goto cleanup;
}
}
if (!(cmd = qemuProcessCreatePretendCmd(conn, driver, vm, NULL, if (!(cmd = qemuProcessCreatePretendCmd(conn, driver, vm, NULL,
qemuCheckFips(), true, qemuCheckFips(), true,
VIR_QEMU_PROCESS_START_COLD))) VIR_QEMU_PROCESS_START_COLD)))
......
...@@ -3856,7 +3856,7 @@ qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver) ...@@ -3856,7 +3856,7 @@ qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver)
virDomainObjListForEach(driver->domains, qemuProcessReconnectHelper, &data); virDomainObjListForEach(driver->domains, qemuProcessReconnectHelper, &data);
} }
int static int
qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver, qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
virDomainGraphicsDefPtr graphics, virDomainGraphicsDefPtr graphics,
bool allocate) bool allocate)
...@@ -3888,7 +3888,7 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver, ...@@ -3888,7 +3888,7 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
return 0; return 0;
} }
int static int
qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver, qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg, virQEMUDriverConfigPtr cfg,
virDomainGraphicsDefPtr graphics, virDomainGraphicsDefPtr graphics,
...@@ -4389,13 +4389,15 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver, ...@@ -4389,13 +4389,15 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
static int static int
qemuProcessSetupGraphics(virQEMUDriverPtr driver, qemuProcessSetupGraphics(virQEMUDriverPtr driver,
virDomainObjPtr vm) virDomainObjPtr vm,
unsigned int flags)
{ {
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND);
size_t i; size_t i;
int ret = -1; int ret = -1;
if (qemuProcessGraphicsReservePorts(driver, vm) < 0) if (allocate && qemuProcessGraphicsReservePorts(driver, vm) < 0)
goto cleanup; goto cleanup;
for (i = 0; i < vm->def->ngraphics; ++i) { for (i = 0; i < vm->def->ngraphics; ++i) {
...@@ -4403,12 +4405,12 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, ...@@ -4403,12 +4405,12 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
switch (graphics->type) { switch (graphics->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_VNC: case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
if (qemuProcessVNCAllocatePorts(driver, graphics, true) < 0) if (qemuProcessVNCAllocatePorts(driver, graphics, allocate) < 0)
goto cleanup; goto cleanup;
break; break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, true) < 0) if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, allocate) < 0)
goto cleanup; goto cleanup;
break; break;
...@@ -5175,6 +5177,10 @@ qemuProcessPrepareDomain(virConnectPtr conn, ...@@ -5175,6 +5177,10 @@ qemuProcessPrepareDomain(virConnectPtr conn,
if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
goto cleanup; goto cleanup;
VIR_DEBUG("Setting up ports for graphics");
if (qemuProcessSetupGraphics(driver, vm, flags) < 0)
goto cleanup;
/* Fill in run-time values for graphics devices. */ /* Fill in run-time values for graphics devices. */
for (i = 0; i < vm->def->ngraphics; i++) { for (i = 0; i < vm->def->ngraphics; i++) {
virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
...@@ -5313,10 +5319,6 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, ...@@ -5313,10 +5319,6 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
VIR_DEBUG("Ensuring no historical cgroup is lying around"); VIR_DEBUG("Ensuring no historical cgroup is lying around");
qemuRemoveCgroup(vm); qemuRemoveCgroup(vm);
VIR_DEBUG("Setting up ports for graphics");
if (qemuProcessSetupGraphics(driver, vm) < 0)
goto cleanup;
if (virFileMakePath(cfg->logDir) < 0) { if (virFileMakePath(cfg->logDir) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("cannot create log directory %s"), _("cannot create log directory %s"),
......
...@@ -175,14 +175,6 @@ bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver, ...@@ -175,14 +175,6 @@ bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver,
int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp, int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp,
virDomainThreadSchedParamPtr sp); virDomainThreadSchedParamPtr sp);
int qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
virDomainGraphicsDefPtr graphics,
bool allocate);
int qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg,
virDomainGraphicsDefPtr graphics,
bool allocate);
virDomainDiskDefPtr qemuProcessFindDomainDiskByAlias(virDomainObjPtr vm, virDomainDiskDefPtr qemuProcessFindDomainDiskByAlias(virDomainObjPtr vm,
const char *alias); const char *alias);
......
...@@ -37,7 +37,7 @@ media=cdrom,id=drive-ide0-1-0 \ ...@@ -37,7 +37,7 @@ media=cdrom,id=drive-ide0-1-0 \
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\ -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
id=channel0,name=com.redhat.spice.0 \ id=channel0,name=com.redhat.spice.0 \
-device usb-tablet,id=input0 \ -device usb-tablet,id=input0 \
-spice port=0 \ -spice port=5901,tls-port=5902,addr=0.0.0.0,x509-dir=/etc/pki/libvirt-spice \
-vga cirrus \ -vga cirrus \
-device intel-hda,id=sound0,bus=pci.0,addr=0x4 \ -device intel-hda,id=sound0,bus=pci.0,addr=0x4 \
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \ -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
......
...@@ -47,7 +47,7 @@ id=channel0,name=org.qemu.guest_agent.0 \ ...@@ -47,7 +47,7 @@ id=channel0,name=org.qemu.guest_agent.0 \
-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\ -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\
id=channel1,name=com.redhat.spice.0 \ id=channel1,name=com.redhat.spice.0 \
-device usb-tablet,id=input0 \ -device usb-tablet,id=input0 \
-spice port=0 \ -spice port=5901,tls-port=5902,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice \
-vga qxl \ -vga qxl \
-global qxl-vga.ram_size=67108864 \ -global qxl-vga.ram_size=67108864 \
-global qxl-vga.vram_size=67108864 \ -global qxl-vga.vram_size=67108864 \
......
...@@ -19,7 +19,7 @@ QEMU_AUDIO_DRV=none \ ...@@ -19,7 +19,7 @@ QEMU_AUDIO_DRV=none \
-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\ -drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\
id=drive-ide0-0-0,cache=none \ id=drive-ide0-0-0,cache=none \
-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
-vnc 127.0.0.1:-5900 \ -vnc 127.0.0.1:0 \
-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,\ -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,\
addr=0x3 \ addr=0x3 \
-device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x4 \ -device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x4 \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册