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
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __QEMU_HOTPLUG_H__
|
|
|
|
# define __QEMU_HOTPLUG_H__
|
|
|
|
|
|
|
|
# include "qemu_conf.h"
|
2012-04-02 13:55:08 +00:00
|
|
|
# include "qemu_domain.h"
|
2010-12-16 16:10:54 +00:00
|
|
|
# include "domain_conf.h"
|
|
|
|
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
|
2014-08-08 08:16:32 +00:00
|
|
|
virConnectPtr conn,
|
2010-12-16 16:10:54 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainDiskDefPtr disk,
|
2014-08-05 11:43:57 +00:00
|
|
|
virStorageSourcePtr newsrc,
|
2010-12-16 16:10:54 +00:00
|
|
|
bool force);
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver,
|
2012-04-02 13:55:08 +00:00
|
|
|
virDomainObjPtr vm,
|
2014-06-15 16:32:56 +00:00
|
|
|
qemuDomainAsyncJob asyncJob);
|
2013-11-21 03:36:25 +00:00
|
|
|
int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainControllerDefPtr controller);
|
2013-07-18 08:58:01 +00:00
|
|
|
int qemuDomainAttachDeviceDiskLive(virConnectPtr conn,
|
|
|
|
virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainDeviceDefPtr dev);
|
2010-12-16 16:10:54 +00:00
|
|
|
int qemuDomainAttachNetDevice(virConnectPtr conn,
|
2012-11-28 16:43:10 +00:00
|
|
|
virQEMUDriverPtr driver,
|
2010-12-16 16:10:54 +00:00
|
|
|
virDomainObjPtr vm,
|
2011-05-04 12:09:09 +00:00
|
|
|
virDomainNetDefPtr net);
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
2011-09-02 15:09:14 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainRedirdevDefPtr hostdev);
|
2014-07-10 15:16:15 +00:00
|
|
|
int qemuDomainAttachHostDevice(virConnectPtr conn,
|
|
|
|
virQEMUDriverPtr driver,
|
2010-12-16 16:10:54 +00:00
|
|
|
virDomainObjPtr vm,
|
2011-05-04 12:09:09 +00:00
|
|
|
virDomainHostdevDefPtr hostdev);
|
2014-12-08 13:48:33 +00:00
|
|
|
int qemuDomainFindGraphicsIndex(virDomainDefPtr def,
|
|
|
|
virDomainGraphicsDefPtr dev);
|
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);
|
2013-07-18 09:00:13 +00:00
|
|
|
int qemuDomainDetachDeviceDiskLive(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainDeviceDefPtr dev);
|
2013-11-21 03:36:25 +00:00
|
|
|
int qemuDomainDetachControllerDevice(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainDeviceDefPtr dev);
|
2014-09-24 12:31:32 +00:00
|
|
|
int qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
|
2010-12-16 16:10:54 +00:00
|
|
|
virDomainObjPtr vm,
|
2011-05-04 12:09:09 +00:00
|
|
|
virDomainDeviceDefPtr dev);
|
2014-09-24 12:31:32 +00:00
|
|
|
int qemuDomainDetachHostDevice(virQEMUDriverPtr driver,
|
2010-12-16 16:10:54 +00:00
|
|
|
virDomainObjPtr vm,
|
2011-05-04 12:09:09 +00:00
|
|
|
virDomainDeviceDefPtr dev);
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainAttachLease(virQEMUDriverPtr driver,
|
2011-05-18 16:20:53 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainLeaseDefPtr lease);
|
2012-11-28 16:43:10 +00:00
|
|
|
int qemuDomainDetachLease(virQEMUDriverPtr driver,
|
2011-05-18 16:20:53 +00:00
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainLeaseDefPtr lease);
|
2013-03-13 10:08:55 +00:00
|
|
|
int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainChrDefPtr chr);
|
|
|
|
int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
virDomainChrDefPtr chr);
|
2010-12-16 16:10:54 +00:00
|
|
|
|
|
|
|
|
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,
|
2013-07-11 15:11:02 +00:00
|
|
|
const char *devAlias);
|
|
|
|
|
2010-12-16 16:10:54 +00:00
|
|
|
#endif /* __QEMU_HOTPLUG_H__ */
|