All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] Fix xm block-configure
Date: Wed, 13 May 2009 14:13:05 +0900	[thread overview]
Message-ID: <51C9D3897F7671kanno.masaki@jp.fujitsu.com> (raw)

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 1096 bytes --]

Hi,

This patch solves problems of xm block-configure command.

In the case of inactive managed domains:
 The following error occurs currently.  We cannot change the configuration 
 of the VBD by using xm block-configure.  Of course, using xm block-detach 
 and xm block-attach instead of xm block-configure, we can change it.
 However, I'd like to change it by using xm block-configure.
 
 # xm block-list vm1
 Vdev  BE handle state evt-ch ring-ref BE-path
 5632   -1   0     -1     -1     -1    ??                              
 # xm block-configure vm1 file:/var/xen/boot.iso hdc:cdrom r
 Error: Device 5632 not connected
 Usage: xm block-configure <Domain> <BackDev> <FrontDev> <Mode> [BackDomain]
 
 Change block device configuration


In the case of active domains:
 Another problem occurs after a domain was rebooted.  Even if we change 
 a configuration of a VBD in the domain by using xm block-configure, the 
 configuration of the VBD is reverted to previous configuration after the 
 domain was rebooted.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>

Best regards,
 Kan


[-- Attachment #2: xm_block_configure.patch --]
[-- Type: application/octet-stream, Size: 2172 bytes --]

diff -r 2522cc95efd2 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py	Mon May 11 13:52:04 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py	Wed May 13 14:07:36 2009 +0900
@@ -1048,14 +1048,41 @@ class XendDomainInfo:
             except IndexError:
                 pass
 
-        # use DevController.reconfigureDevice to change device config
         dev_control = self.getDeviceController(dev_class)
-        dev_uuid = dev_control.reconfigureDevice(devid, dev_config)
+        if devid is None:
+            dev = dev_config.get('dev', '')
+            if not dev:
+                raise VmError('Block device must have virtual details specified')
+            if 'ioemu:' in dev:
+                (_, dev) = dev.split(':', 1)
+            try:
+                (dev, _) = dev.split(':', 1)  # Remove ":disk" or ":cdrom"
+            except ValueError:
+                pass
+            devid = dev_control.convertToDeviceNumber(dev)
+        dev_info = self._getDeviceInfo_vbd(devid)
+        if dev_info is None:
+            raise VmError("Device %s not connected" % devid)
+        dev_uuid = sxp.child_value(dev_info, 'uuid')
+
+        if self.domid is not None:
+            # use DevController.reconfigureDevice to change device config
+            dev_control.reconfigureDevice(devid, dev_config)
+        else:
+            (_, new_b, new_f) = dev_control.getDeviceDetails(dev_config)
+            if (new_f['device-type'] == 'cdrom' and
+                sxp.child_value(dev_info, 'dev').endswith(':cdrom') and
+                new_b['mode'] == 'r' and
+                sxp.child_value(dev_info, 'mode') == 'r'):
+                pass
+            else:
+                raise VmError('Refusing to reconfigure device %s:%d to %s' %
+                              (dev_class, devid, dev_config))
 
         # update XendConfig with new device info
-        if dev_uuid:
-            self.info.device_update(dev_uuid, dev_sxp)
-            
+        self.info.device_update(dev_uuid, dev_sxp)
+        xen.xend.XendDomain.instance().managed_config_save(self)
+
         return True
 
     def waitForDevices(self):

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2009-05-13  5:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51C9D3897F7671kanno.masaki@jp.fujitsu.com \
    --to=kanno.masaki@jp.fujitsu.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.