提交 984c01ba 编写于 作者: J Jiri Denemark

qemu: Emit VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED events

上级 3fbf78bd
......@@ -2234,6 +2234,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk)
{
virDomainDeviceDef dev;
virDomainEventPtr event;
size_t i;
VIR_DEBUG("Removing disk %s from domain %p %s",
......@@ -2241,6 +2242,10 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
virDomainAuditDisk(vm, disk->src, NULL, "detach", true);
event = virDomainEventDeviceRemovedNewFromObj(vm, disk->info.alias);
if (event)
qemuDomainEventQueue(driver, event);
for (i = 0; i < vm->def->ndisks; i++) {
if (vm->def->disks[i] == disk) {
virDomainDiskRemove(vm->def, i);
......@@ -2269,15 +2274,20 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
static void
qemuDomainRemoveControllerDevice(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
qemuDomainRemoveControllerDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainControllerDefPtr controller)
{
virDomainEventPtr event;
size_t i;
VIR_DEBUG("Removing controller %s from domain %p %s",
controller->info.alias, vm, vm->def->name);
event = virDomainEventDeviceRemovedNewFromObj(vm, controller->info.alias);
if (event)
qemuDomainEventQueue(driver, event);
for (i = 0; i < vm->def->ncontrollers; i++) {
if (vm->def->controllers[i] == controller) {
virDomainControllerRemove(vm->def, i);
......@@ -2297,6 +2307,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
{
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virNetDevVPortProfilePtr vport;
virDomainEventPtr event;
size_t i;
VIR_DEBUG("Removing network interface %s from domain %p %s",
......@@ -2304,6 +2315,10 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
virDomainAuditNet(vm, net, NULL, "detach", true);
event = virDomainEventDeviceRemovedNewFromObj(vm, net->info.alias);
if (event)
qemuDomainEventQueue(driver, event);
for (i = 0; i < vm->def->nnets; i++) {
if (vm->def->nets[i] == net) {
virDomainNetRemove(vm->def, i);
......@@ -2420,11 +2435,16 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
virDomainHostdevDefPtr hostdev)
{
virDomainNetDefPtr net = NULL;
virDomainEventPtr event;
size_t i;
VIR_DEBUG("Removing host device %s from domain %p %s",
hostdev->info->alias, vm, vm->def->name);
event = virDomainEventDeviceRemovedNewFromObj(vm, hostdev->info->alias);
if (event)
qemuDomainEventQueue(driver, event);
if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET) {
net = hostdev->parent.data.net;
......@@ -2477,13 +2497,19 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
static void
qemuDomainRemoveChrDevice(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainChrDefPtr chr)
{
virDomainEventPtr event;
VIR_DEBUG("Removing character device %s from domain %p %s",
chr->info.alias, vm, vm->def->name);
event = virDomainEventDeviceRemovedNewFromObj(vm, chr->info.alias);
if (event)
qemuDomainEventQueue(driver, event);
qemuDomainChrRemove(vm->def, chr);
virDomainChrDefFree(chr);
}
......
......@@ -269,6 +269,9 @@ mymain(void)
VIR_FREE(driver.config->spiceListen);
VIR_FREE(driver.config->vncListen);
if (!(driver.domainEventState = virDomainEventStateNew()))
return EXIT_FAILURE;
/* some dummy values from 'config file' */
if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
return EXIT_FAILURE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册