mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
Support virDomainOpenConsole with QEMU
This provides an implementation of the virDomainOpenConsole API with the QEMU driver. For the streams code, this reuses most of the code previously added for the tunnelled migration streams since it is generic. * src/qemu/qemu_driver.c: Support virDomainOpenConsole
This commit is contained in:
parent
7c08fcc439
commit
bdb28f4426
@ -13051,6 +13051,82 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainOpenConsole(virDomainPtr dom,
|
||||||
|
const char *devname,
|
||||||
|
virStreamPtr st,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
|
virDomainObjPtr vm = NULL;
|
||||||
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
|
int ret = -1;
|
||||||
|
int i;
|
||||||
|
virDomainChrDefPtr chr = NULL;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
|
qemuDriverLock(driver);
|
||||||
|
virUUIDFormat(dom->uuid, uuidstr);
|
||||||
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
|
if (!vm) {
|
||||||
|
qemuReportError(VIR_ERR_NO_DOMAIN,
|
||||||
|
_("no domain with matching uuid '%s'"), uuidstr);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!virDomainObjIsActive(vm)) {
|
||||||
|
qemuReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
|
"%s", _("domain is not running"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (devname) {
|
||||||
|
if (vm->def->console &&
|
||||||
|
STREQ(devname, vm->def->console->info.alias))
|
||||||
|
chr = vm->def->console;
|
||||||
|
for (i = 0 ; !chr && i < vm->def->nserials ; i++) {
|
||||||
|
if (STREQ(devname, vm->def->serials[i]->info.alias))
|
||||||
|
chr = vm->def->serials[i];
|
||||||
|
}
|
||||||
|
for (i = 0 ; !chr && i < vm->def->nparallels ; i++) {
|
||||||
|
if (STREQ(devname, vm->def->parallels[i]->info.alias))
|
||||||
|
chr = vm->def->parallels[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (vm->def->console)
|
||||||
|
chr = vm->def->console;
|
||||||
|
else if (vm->def->nserials)
|
||||||
|
chr = vm->def->serials[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!chr) {
|
||||||
|
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("cannot find character device %s"),
|
||||||
|
NULLSTR(devname));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chr->type != VIR_DOMAIN_CHR_TYPE_PTY) {
|
||||||
|
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("character device %s is not using a PTY"),
|
||||||
|
NULLSTR(devname));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virFDStreamOpenFile(st, chr->data.file.path, O_RDWR) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
if (vm)
|
||||||
|
virDomainObjUnlock(vm);
|
||||||
|
qemuDriverUnlock(driver);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static virDriver qemuDriver = {
|
static virDriver qemuDriver = {
|
||||||
VIR_DRV_QEMU,
|
VIR_DRV_QEMU,
|
||||||
"QEMU",
|
"QEMU",
|
||||||
@ -13155,7 +13231,7 @@ static virDriver qemuDriver = {
|
|||||||
qemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
|
qemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
|
||||||
qemuDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
qemuDomainSetMemoryParameters, /* domainSetMemoryParameters */
|
||||||
qemuDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
qemuDomainGetMemoryParameters, /* domainGetMemoryParameters */
|
||||||
NULL, /* domainOpenConsole */
|
qemuDomainOpenConsole, /* domainOpenConsole */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user