[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH v2] xen: Prevent updating device when attaching a device

于 2011年02月11日 16:07, Osier Yang 写道:
于 2011年02月10日 14:09, Daniel Veillard 写道:
On Wed, Feb 09, 2011 at 02:01:25PM +0000, Daniel P. Berrange wrote:
On Wed, Feb 09, 2011 at 04:51:27PM +0800, Osier Yang wrote:
When attaching a device that already exists, xend driver updates
the device with "device_configure", it causes problems (e.g. for
disk device, 'device_configure' only can be used to update device
like CDROM), on the other hand, we provide additional API
(virDomainUpdateDevice) to update device, this fix is to raise up
errors instead of updating the existed device which is not CDROM

Changes from v1 to v2:
- allow update CDROM

* src/xen/xend_internal.c
src/xen/xend_internal.c | 42 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index cd30336..bc23595 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -3965,6 +3965,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr
domain, const char *xml,
virDomainDefPtr def = NULL;
char class[8], ref[80];
+ char *target = NULL;

if ((domain == NULL) || (domain->conn == NULL) || (domain->name ==
NULL)) {
@@ -4029,6 +4030,13 @@ xenDaemonAttachDeviceFlags(virDomainPtr
domain, const char *xml,
STREQ(def->os.type, "hvm") ? 1 : 0,
priv->xendConfigVersion, 1)< 0)
goto cleanup;
+ if (dev->data.disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM) {

I can't remember if Xen supports it or not, but do we need DEVICE_FLOPPY
here too ?

I would guess that yes, we use it in the xend driver

The patch looks good aside from that question


Checked xend's code, from the code, floppy device updating is not
supported, and also tried to update a floppy device via "xm",
that's true.

file: "xend/server/blkif.py"

def reconfigureDevice(self, _, config):
"""@see DevController.reconfigureDevice"""
(devid, new_back, new_front) = self.getDeviceDetails(config)

(dev, mode) = self.readBackend(devid, 'dev', 'mode')
dev_type = self.readFrontend(devid, 'device-type')

if (dev_type == 'cdrom' and new_front['device-type'] == 'cdrom' and
dev == new_back['dev'] and mode == 'r'):

if not os.access(new_back['params'],os.R_OK):
raise VmError("Can't read disk file %s" % new_back['params'])

'type', new_back['type'],
'params', new_back['params'])
raise VmError('Refusing to reconfigure device %s:%d to %s' %
(self.deviceClass, devid, config))

[root dhcp exp]# xm block-list RHEL5-hvm-64
Vdev BE handle state evt-ch ring-ref BE-path
51712 0 0 1 -1 -1 /local/domain/0/backend/tap/18/51712
4058 0 0 1 -1 -1 /local/domain/0/backend/vbd/18/4058

[root dhcp- exp]# xm block-configure 18
file:/var/lib/xen/images/floppy.img fda:floppy r
Error: Refusing to reconfigure device vbd:4058 to ['vbd', ['uname',
'file:/var/lib/xen/images/floppy.img'], ['dev', 'fda:floppy'], ['mode',

so I will push the patch.




libvir-list mailing list
libvir-list redhat com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]