2010-12-16 16:10:54 +00:00
|
|
|
/*
|
|
|
|
* qemu_hotplug.h: QEMU device hotplug management
|
|
|
|
*
|
qemu: reorganize qemuDomainChangeNet and qemuDomainChangeNetBridge
This patch resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=805071
to the extent that it can be resolved with current qemu functionality.
It attempts to detect as many situations as possible when the simple
operation of disconnecting an existing tap device from one bridge and
attaching it to another will satisfy the change requested in
virDomainUpdateDeviceFlags() for a network device. Before this patch,
that situation could only be detected if the pre-change interface
*and* the post-change interface definition were both "type='bridge'".
After this patch, it can also be detected if the before or after
interfaces are any combination of type='bridge' and type='network'
(the networks can be <forward mode='nat|route|bridge'>, as long as
they use a Linux host bridge and not macvtap connections).
This extra effort is especially useful since the recent discovery that
a netdev_del+netdev_add combo (to reconnect the network device with
completely different hostside configuration) doesn't work properly
with current qemu (1.2) unless it is accompanied by the matching
device_del+device_add - see this mailing list message for details:
http://lists.nongnu.org/archive/html/qemu-devel/2012-10/msg02355.html
(A slight modification of the patch referenced there has been prepared
to apply on top of this patch, but won't be pushed until qemu can be
made to work with it.)
* qemuDomainChangeNet needs access to the virDomainDeviceDef that
holds the new netdef (so that it can clear out the virDomainDeviceDef
if it ends up using the NetDef to replace the original), so the
virDomainNetDefPtr arg is replaced with a virDomainDeviceDefPtr.
* qemuDomainChangeNet previously checked for *some* changes to the
interface config, but this check was by no means complete. It was also
a bit disorganized.
This refactoring of the code is (I believe) complete in its check of
all NetDef attributes that might be changed, and either returns a
failure (for changes that are simply impossible), or sets one of three
flags:
needLinkStateChange - if the device link state needs to go up/down
needBridgeChange - if everything else is the same, but it needs
to be connected to a difference linux host
bridge
needReconnect - if the entire host side of the device needs
to be torn down and reconstructed (currently
non-working, as mentioned above)
Note that this function will refuse to make any change that requires
the *guest* side of the device to be detached (e.g. changing the PCI
address or mac address). Those would be disruptive enough to the guest
that it's reasonable to require an explicit detach/attach sequence
from the management application.
* As mentioned above, qemuDomainChangeNet also does its best to
understand when a simple change in attached bridge for the existing
tap device will work vs. the need to completely tear down/reconstruct
the host side of the device (including tap device).
This patch *does not* implement the "reconnect" code anyway - there is
a placeholder that turns that into an error. Rather, the purpose of
this patch is to replicate existing behavior with code that is ready
to have that functionality plugged in in a later patch.
* The expanded uses for qemuDomainChangeNetBridge meant that it needed
to be enhanced as well - it no longer replaces the original brname
string in olddev with the new brname; instead, it relies on the
caller to replace the *entire* olddev with newdev (since we've gone
to great lengths to assure they are functionally identical other
than the name of the bridge, this is now not only safe, but more
correct). Additionally, qemuDomainNetChangeBridge can now set the
bridge for type='network' interfaces as well as plain type='bridge'
interfaces. (Note that I had to make this change simultaneous to the
reorganization of qemuDomainChangeNet because the two are too
closely intertwined to separate).
2012-10-10 19:38:00 +00:00
|
|
|
* Copyright (C) 2006-2007, 2009-2012 Red Hat, Inc.
|
2010-12-16 16:10:54 +00:00
|
|
|
* Copyright (C) 2006 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2010-12-16 16:10:54 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-18 16:12:37 +00:00
|
|
|
#pragma once
|
2010-12-16 16:10:54 +00:00
|
|
|
|
2019-06-18 16:12:37 +00:00
|
|
|
#include "qemu_conf.h"
|
|
|
|
#include "qemu_domain.h"
|
|
|
|
#include "domain_conf.h"
|
2010-12-16 16:10:54 +00:00
|
|
|
|
2018-09-25 12:21:27 +00:00
|
|
|
int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainDiskDefPtr disk,
|
|
|
|
virStorageSourcePtr newsrc,
|
|
|
|
bool force);
|
|
|
|
|
2017-02-16 15:33:35 +00:00
|
|
|
void qemuDomainDelTLSObjects(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
2017-03-09 14:20:27 +00:00
|
|
|
qemuDomainAsyncJob asyncJob,
|
2017-02-16 15:33:35 +00:00
|
|
|
const char *secAlias,
|
|
|
|
const char *tlsAlias);
|
|
|
|
|
|
|
|
int qemuDomainAddTLSObjects(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
2017-03-09 14:20:27 +00:00
|
|
|
qemuDomainAsyncJob asyncJob,
|
2017-02-16 15:33:35 +00:00
|
|
|
virJSONValuePtr *secProps,
|
|
|
|
virJSONValuePtr *tlsProps);
|
|
|
|
|
2017-02-17 15:06:14 +00:00
|
|
|
int qemuDomainGetTLSObjects(virQEMUCapsPtr qemuCaps,
|
|
|
|
qemuDomainSecretInfoPtr secinfo,
|
|
|
|
const char *tlsCertdir,
|
|
|
|
bool tlsListen,
|
|
|
|
bool tlsVerify,
|
2018-05-22 05:38:22 +00:00
|
|
|
const char *alias,
|
2017-02-17 15:06:14 +00:00
|
|
|
virJSONValuePtr *tlsProps,
|
2018-05-29 18:17:04 +00:00
|
|
|
virJSONValuePtr *secProps);
|
2017-02-17 15:06:14 +00:00
|
|
|
|
2013-11-21 03:36:25 +00:00
|
|
|
int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainControllerDefPtr controller);
|
2018-02-09 16:14:41 +00:00
|
|
|
int qemuDomainAttachDeviceDiskLive(virQEMUDriverPtr driver,
|
2013-07-18 08:58:01 +00:00
|
|
|
virDomainObjPtr vm,
|
2018-09-25 12:21:27 +00:00
|
|
|
virDomainDeviceDefPtr dev);
|
2016-04-06 14:41:33 +00:00
|
|
|
int qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
2010-12-16 16:10:54 +00:00
|
|
|
virDomainObjPtr vm,
|
2011-05-04 12:09:09 +00:00
|
|
|
virDomainNetDefPtr net);
|
2018-02-09 16:14:41 +00:00
|
|
|
int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
2011-09-02 15:09:14 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainRedirdevDefPtr hostdev);
|
2018-02-09 16:14:41 +00:00
|
|
|
int qemuDomainAttachHostDevice(virQEMUDriverPtr driver,
|
2010-12-16 16:10:54 +00:00
|
|
|
virDomainObjPtr vm,
|
2011-05-04 12:09:09 +00:00
|
|
|
virDomainHostdevDefPtr hostdev);
|
2016-09-12 13:40:48 +00:00
|
|
|
int qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainShmemDefPtr shmem);
|
2017-09-01 11:39:15 +00:00
|
|
|
int qemuDomainAttachWatchdog(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainWatchdogDefPtr watchdog);
|
2014-12-08 13:48:33 +00:00
|
|
|
int qemuDomainFindGraphicsIndex(virDomainDefPtr def,
|
|
|
|
virDomainGraphicsDefPtr dev);
|
2014-10-12 22:28:58 +00:00
|
|
|
int qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainMemoryDefPtr mem);
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainChangeGraphics(virQEMUDriverPtr driver,
|
2010-12-16 16:10:54 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainGraphicsDefPtr dev);
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
Use the new set_password monitor command to set password.
We try to use that command first when setting a VNC/SPICE password. If
that doesn't work we fallback to the legacy VNC only password
Allow an expiry time to be set, if that doesn't work, throw an error
if they try to use SPICE.
Change since v1:
- moved qemuInitGraphicsPasswords to qemu_hotplug, renamed
to qemuDomainChangeGraphicsPasswords.
- updated what looks like a typo (that appears to work anyway) in
initial patch from Daniel:
- ret = qemuInitGraphicsPasswords(driver, vm,
- VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
- &vm->def->graphics[0]->data.vnc.auth,
- driver->vncPassword);
+ ret = qemuInitGraphicsPasswords(driver, vm,
+ VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
+ &vm->def->graphics[0]->data.spice.auth,
+ driver->spicePassword);
Based on patch by Daniel P. Berrange <berrange@redhat.com>.
2011-01-10 11:12:33 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
int type,
|
|
|
|
virDomainGraphicsAuthDefPtr auth,
|
2014-08-12 02:54:42 +00:00
|
|
|
const char *defaultPasswd,
|
|
|
|
int asyncJob);
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainChangeNet(virQEMUDriverPtr driver,
|
2011-09-06 08:23:47 +00:00
|
|
|
virDomainObjPtr vm,
|
qemu: reorganize qemuDomainChangeNet and qemuDomainChangeNetBridge
This patch resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=805071
to the extent that it can be resolved with current qemu functionality.
It attempts to detect as many situations as possible when the simple
operation of disconnecting an existing tap device from one bridge and
attaching it to another will satisfy the change requested in
virDomainUpdateDeviceFlags() for a network device. Before this patch,
that situation could only be detected if the pre-change interface
*and* the post-change interface definition were both "type='bridge'".
After this patch, it can also be detected if the before or after
interfaces are any combination of type='bridge' and type='network'
(the networks can be <forward mode='nat|route|bridge'>, as long as
they use a Linux host bridge and not macvtap connections).
This extra effort is especially useful since the recent discovery that
a netdev_del+netdev_add combo (to reconnect the network device with
completely different hostside configuration) doesn't work properly
with current qemu (1.2) unless it is accompanied by the matching
device_del+device_add - see this mailing list message for details:
http://lists.nongnu.org/archive/html/qemu-devel/2012-10/msg02355.html
(A slight modification of the patch referenced there has been prepared
to apply on top of this patch, but won't be pushed until qemu can be
made to work with it.)
* qemuDomainChangeNet needs access to the virDomainDeviceDef that
holds the new netdef (so that it can clear out the virDomainDeviceDef
if it ends up using the NetDef to replace the original), so the
virDomainNetDefPtr arg is replaced with a virDomainDeviceDefPtr.
* qemuDomainChangeNet previously checked for *some* changes to the
interface config, but this check was by no means complete. It was also
a bit disorganized.
This refactoring of the code is (I believe) complete in its check of
all NetDef attributes that might be changed, and either returns a
failure (for changes that are simply impossible), or sets one of three
flags:
needLinkStateChange - if the device link state needs to go up/down
needBridgeChange - if everything else is the same, but it needs
to be connected to a difference linux host
bridge
needReconnect - if the entire host side of the device needs
to be torn down and reconstructed (currently
non-working, as mentioned above)
Note that this function will refuse to make any change that requires
the *guest* side of the device to be detached (e.g. changing the PCI
address or mac address). Those would be disruptive enough to the guest
that it's reasonable to require an explicit detach/attach sequence
from the management application.
* As mentioned above, qemuDomainChangeNet also does its best to
understand when a simple change in attached bridge for the existing
tap device will work vs. the need to completely tear down/reconstruct
the host side of the device (including tap device).
This patch *does not* implement the "reconnect" code anyway - there is
a placeholder that turns that into an error. Rather, the purpose of
this patch is to replicate existing behavior with code that is ready
to have that functionality plugged in in a later patch.
* The expanded uses for qemuDomainChangeNetBridge meant that it needed
to be enhanced as well - it no longer replaces the original brname
string in olddev with the new brname; instead, it relies on the
caller to replace the *entire* olddev with newdev (since we've gone
to great lengths to assure they are functionally identical other
than the name of the bridge, this is now not only safe, but more
correct). Additionally, qemuDomainNetChangeBridge can now set the
bridge for type='network' interfaces as well as plain type='bridge'
interfaces. (Note that I had to make this change simultaneous to the
reorganization of qemuDomainChangeNet because the two are too
closely intertwined to separate).
2012-10-10 19:38:00 +00:00
|
|
|
virDomainDeviceDefPtr dev);
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainChangeNetLinkState(virQEMUDriverPtr driver,
|
2011-09-06 08:23:47 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainNetDefPtr dev,
|
|
|
|
int linkstate);
|
2018-01-05 02:47:47 +00:00
|
|
|
|
2017-10-04 09:09:27 +00:00
|
|
|
int qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainInputDefPtr input);
|
|
|
|
|
2018-05-30 11:53:52 +00:00
|
|
|
int qemuDomainAttachVsockDevice(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainVsockDefPtr vsock);
|
|
|
|
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainAttachLease(virQEMUDriverPtr driver,
|
2011-05-18 16:20:53 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainLeaseDefPtr lease);
|
2018-02-09 16:14:41 +00:00
|
|
|
int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
2013-03-13 10:08:55 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainChrDefPtr chr);
|
2018-02-09 16:14:41 +00:00
|
|
|
int qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
|
2015-01-17 05:09:37 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainRNGDefPtr rng);
|
2010-12-16 16:10:54 +00:00
|
|
|
|
2019-03-19 17:55:13 +00:00
|
|
|
int qemuDomainDetachDeviceLive(virDomainObjPtr vm,
|
2019-03-19 21:15:00 +00:00
|
|
|
virDomainDeviceDefPtr match,
|
2019-03-19 17:55:13 +00:00
|
|
|
virQEMUDriverPtr driver,
|
|
|
|
bool async);
|
|
|
|
|
2016-08-16 13:02:11 +00:00
|
|
|
void qemuDomainRemoveVcpuAlias(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
const char *alias);
|
|
|
|
|
2013-03-12 14:59:25 +00:00
|
|
|
int
|
|
|
|
qemuDomainChrInsert(virDomainDefPtr vmdef,
|
|
|
|
virDomainChrDefPtr chr);
|
|
|
|
virDomainChrDefPtr
|
|
|
|
qemuDomainChrRemove(virDomainDefPtr vmdef,
|
|
|
|
virDomainChrDefPtr chr);
|
|
|
|
|
2014-12-16 14:50:20 +00:00
|
|
|
int qemuDomainRemoveDevice(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainDeviceDefPtr dev);
|
2013-07-11 15:11:02 +00:00
|
|
|
|
2014-05-26 15:01:52 +00:00
|
|
|
bool qemuDomainSignalDeviceRemoval(virDomainObjPtr vm,
|
2016-04-04 15:17:43 +00:00
|
|
|
const char *devAlias,
|
|
|
|
qemuDomainUnpluggingDeviceStatus status);
|
2013-07-11 15:11:02 +00:00
|
|
|
|
2016-11-24 15:56:56 +00:00
|
|
|
int qemuDomainSetVcpusInternal(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainDefPtr def,
|
|
|
|
virDomainDefPtr persistentDef,
|
|
|
|
unsigned int nvcpus,
|
|
|
|
bool hotpluggable);
|
|
|
|
|
2016-06-21 15:17:41 +00:00
|
|
|
int qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainDefPtr def,
|
|
|
|
virDomainDefPtr persistentDef,
|
|
|
|
virBitmapPtr vcpus,
|
|
|
|
bool state);
|
2019-08-08 14:55:00 +00:00
|
|
|
|
2020-08-04 14:17:07 +00:00
|
|
|
unsigned long long qemuDomainGetUnplugTimeout(virDomainObjPtr vm) G_GNUC_NO_INLINE;
|
2020-02-25 09:55:11 +00:00
|
|
|
|
|
|
|
int qemuHotplugAttachDBusVMState(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
qemuDomainAsyncJob asyncJob);
|
|
|
|
|
|
|
|
int qemuHotplugRemoveDBusVMState(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
qemuDomainAsyncJob asyncJob);
|