mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
graphics: generate fake ports also for tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
446aebbcf6
commit
9f51c1c7c7
@ -7060,18 +7060,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
|
||||
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,
|
||||
qemuCheckFips(), true,
|
||||
VIR_QEMU_PROCESS_START_COLD)))
|
||||
|
@ -3856,7 +3856,7 @@ qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver)
|
||||
virDomainObjListForEach(driver->domains, qemuProcessReconnectHelper, &data);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
|
||||
virDomainGraphicsDefPtr graphics,
|
||||
bool allocate)
|
||||
@ -3888,7 +3888,7 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
virDomainGraphicsDefPtr graphics,
|
||||
@ -4389,13 +4389,15 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
|
||||
|
||||
static int
|
||||
qemuProcessSetupGraphics(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm)
|
||||
virDomainObjPtr vm,
|
||||
unsigned int flags)
|
||||
{
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND);
|
||||
size_t i;
|
||||
int ret = -1;
|
||||
|
||||
if (qemuProcessGraphicsReservePorts(driver, vm) < 0)
|
||||
if (allocate && qemuProcessGraphicsReservePorts(driver, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
for (i = 0; i < vm->def->ngraphics; ++i) {
|
||||
@ -4403,12 +4405,12 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
|
||||
|
||||
switch (graphics->type) {
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||
if (qemuProcessVNCAllocatePorts(driver, graphics, true) < 0)
|
||||
if (qemuProcessVNCAllocatePorts(driver, graphics, allocate) < 0)
|
||||
goto cleanup;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
||||
if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, true) < 0)
|
||||
if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, allocate) < 0)
|
||||
goto cleanup;
|
||||
break;
|
||||
|
||||
@ -5175,6 +5177,10 @@ qemuProcessPrepareDomain(virConnectPtr conn,
|
||||
if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
|
||||
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. */
|
||||
for (i = 0; i < vm->def->ngraphics; i++) {
|
||||
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
|
||||
@ -5313,10 +5319,6 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
|
||||
VIR_DEBUG("Ensuring no historical cgroup is lying around");
|
||||
qemuRemoveCgroup(vm);
|
||||
|
||||
VIR_DEBUG("Setting up ports for graphics");
|
||||
if (qemuProcessSetupGraphics(driver, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virFileMakePath(cfg->logDir) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("cannot create log directory %s"),
|
||||
|
@ -175,14 +175,6 @@ bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver,
|
||||
int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp,
|
||||
virDomainThreadSchedParamPtr sp);
|
||||
|
||||
int qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
|
||||
virDomainGraphicsDefPtr graphics,
|
||||
bool allocate);
|
||||
int qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
|
||||
virQEMUDriverConfigPtr cfg,
|
||||
virDomainGraphicsDefPtr graphics,
|
||||
bool allocate);
|
||||
|
||||
virDomainDiskDefPtr qemuProcessFindDomainDiskByAlias(virDomainObjPtr vm,
|
||||
const char *alias);
|
||||
|
||||
|
@ -37,7 +37,7 @@ media=cdrom,id=drive-ide0-1-0 \
|
||||
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
|
||||
id=channel0,name=com.redhat.spice.0 \
|
||||
-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 \
|
||||
-device intel-hda,id=sound0,bus=pci.0,addr=0x4 \
|
||||
-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
|
||||
|
@ -47,7 +47,7 @@ id=channel0,name=org.qemu.guest_agent.0 \
|
||||
-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\
|
||||
id=channel1,name=com.redhat.spice.0 \
|
||||
-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 \
|
||||
-global qxl-vga.ram_size=67108864 \
|
||||
-global qxl-vga.vram_size=67108864 \
|
||||
|
@ -19,7 +19,7 @@ QEMU_AUDIO_DRV=none \
|
||||
-drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=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 \
|
||||
-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,\
|
||||
addr=0x3 \
|
||||
-device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x4 \
|
||||
|
Loading…
x
Reference in New Issue
Block a user