mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
qemu: Honour 'virtlogd' use when hotplugging chardevs
Setup the chardev similarly to how we do it on startup so that virtlogd is properly used with chardevs which are hotplugged to a VM. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d86bfa631e
commit
ad81aa8ad0
@ -6730,8 +6730,7 @@ qemuDomainAttachDeviceLive(virDomainObj *vm,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_CHR:
|
||||
ret = qemuDomainAttachChrDevice(driver, vm,
|
||||
dev->data.chr);
|
||||
ret = qemuDomainAttachChrDevice(driver, vm, dev);
|
||||
if (!ret) {
|
||||
alias = dev->data.chr->info.alias;
|
||||
dev->data.chr = NULL;
|
||||
|
@ -2180,10 +2180,14 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainObj *vm,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qemuDomainAttachChrDevice(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
virDomainChrDef *chr)
|
||||
|
||||
int
|
||||
qemuDomainAttachChrDevice(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
virDomainDeviceDef *dev)
|
||||
{
|
||||
virDomainChrDef *chr = dev->data.chr;
|
||||
qemuDomainChrSourcePrivate *charpriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(chr->source);
|
||||
int ret = -1;
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
virErrorPtr orig_err;
|
||||
@ -2224,6 +2228,19 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver,
|
||||
goto cleanup;
|
||||
teardowncgroup = true;
|
||||
|
||||
if (qemuProcessPrepareHostBackendChardevHotplug(vm, dev) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (charpriv->sourcefd || charpriv->logfd) {
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
|
||||
if (qemuFDPassTransferMonitor(charpriv->sourcefd, priv->mon) < 0 ||
|
||||
qemuFDPassTransferMonitor(charpriv->logfd, priv->mon) < 0)
|
||||
goto exit_monitor;
|
||||
|
||||
qemuDomainObjExitMonitor(driver, vm);
|
||||
}
|
||||
|
||||
if (guestfwd) {
|
||||
if (!(netdevprops = qemuBuildChannelGuestfwdNetdevProps(chr)))
|
||||
goto cleanup;
|
||||
@ -2286,6 +2303,8 @@ int qemuDomainAttachChrDevice(virQEMUDriver *driver,
|
||||
/* detach associated chardev on error */
|
||||
if (chardevAttached)
|
||||
qemuMonitorDetachCharDev(priv->mon, charAlias);
|
||||
qemuFDPassTransferMonitorRollback(charpriv->sourcefd, priv->mon);
|
||||
qemuFDPassTransferMonitorRollback(charpriv->logfd, priv->mon);
|
||||
qemuDomainObjExitMonitor(driver, vm);
|
||||
virErrorRestore(&orig_err);
|
||||
|
||||
|
@ -117,7 +117,7 @@ int qemuDomainAttachLease(virQEMUDriver *driver,
|
||||
virDomainLeaseDef *lease);
|
||||
int qemuDomainAttachChrDevice(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
virDomainChrDef *chr);
|
||||
virDomainDeviceDef *dev);
|
||||
int qemuDomainAttachRNGDevice(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
virDomainRNGDef *rng);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "qemu/qemu_hotplug.h"
|
||||
#include "qemu/qemu_interface.h"
|
||||
#include "qemu/qemu_process.h"
|
||||
#include "testutilsqemu.h"
|
||||
#include "conf/domain_conf.h"
|
||||
#include "virdevmapper.h"
|
||||
#include "virutil.h"
|
||||
@ -96,3 +97,13 @@ qemuInterfaceVDPAConnect(virDomainNetDef *net G_GNUC_UNUSED)
|
||||
/* need a valid fd or sendmsg won't work. Just open /dev/null */
|
||||
return open("/dev/null", O_RDONLY);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuProcessPrepareHostBackendChardevHotplug(virDomainObj *vm,
|
||||
virDomainDeviceDef *dev)
|
||||
{
|
||||
return qemuDomainDeviceBackendChardevForeachOne(dev,
|
||||
testQemuPrepareHostBackendChardevOne,
|
||||
vm);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ testQemuHotplugAttach(virDomainObj *vm,
|
||||
ret = qemuDomainAttachDeviceDiskLive(&driver, vm, dev);
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_CHR:
|
||||
ret = qemuDomainAttachChrDevice(&driver, vm, dev->data.chr);
|
||||
ret = qemuDomainAttachChrDevice(&driver, vm, dev);
|
||||
break;
|
||||
case VIR_DOMAIN_DEVICE_SHMEM:
|
||||
ret = qemuDomainAttachShmemDevice(&driver, vm, dev->data.shmem);
|
||||
|
Loading…
Reference in New Issue
Block a user