* Re: [PATCH] Fix xm block/network-detach command
@ 2007-08-03 20:48 Jim Fehlig
2007-08-06 11:52 ` Masaki Kanno
2007-08-07 0:52 ` Jim Fehlig
0 siblings, 2 replies; 6+ messages in thread
From: Jim Fehlig @ 2007-08-03 20:48 UTC (permalink / raw)
To: Masaki Kanno; +Cc: xen-devel, mats
Masaki Kanno wrote:
> Hi,
>
> This patch fixes a few problem of xm block/network-detach command.
>
> At first, when I tested xm block/network-detach command to a inactive
> managed domain, I saw the following error messages.
>
> # xm new /xen/vm1.conf
> Using config file "/xen/vm1.conf".
> # xm list --long vm1
> (domain
> <snip>
> (device
> (vif
> (mac 00:16:3e:75:96:d8)
> (uuid ebd29601-41ac-75de-87cd-2ae051fa8719)
> )
> )
> (device
> (vbd
> (uuid 7572ae87-5706-217a-3fa5-f68496e147c1)
> (bootable 1)
> (driver paravirtualised)
> (dev hda1)
> (uname file:/xen/rhel4u2.root.img-vm1)
> (mode w)
> )
> )
> )
> # xm block-detach vm1 hda1
> Error: Device hda1 not connected
> Usage: xm block-detach <Domain> <DevId> [-f|--force]
>
> Destroy a domain's virtual block device.
> # xm network-detach vm1 0
> Error: (22, 'Invalid argument, while reading None/device/vif/0/backend')
> Usage: xm network-detach <Domain> <DevId> [-f|--force]
>
> Destroy a domain's virtual network device.
>
>
> I was able to fix the problem of inactive managed domains by writing
> a small patch.
This brings up a broader question concerning managed domains. What is
the behavior when changing config of a managed domain?
a)
- persist change to store and modify domain if live
b)
- explicitly change live config
- explicitly change stored config
Some of the xm commands support a). That would be behavior of
block-detach with this patch.
It appears Xen API supports b) given the *_live, plug, and unplug
operations defined in the spec. I have noticed this to be the case for
some resource types, but doubt it is consistent across all resource
types - let alone both Xen API and legacy sxpr interfaces.
IMO, since xen itself now supports managed domains it should be possible
to independently change live and stored config. I should be able to feed
a starving domain but have it revert to default (define by me) settings
when reset. That said I think it will be considerable work, particularly
testing, to ensure this behavior across all resource types and xend
interfaces.
> However, I found a other problem in xm block/network-
> detach command when I tested xm block/network-detach command more.
> The other problem is the same as the problem that Mats reported in
> the following.
>
> http://lists.xensource.com/archives/html/xen-devel/2007-08/msg00040.html
>
That patch did not cause any problems with save.
> This patch fixes the other problem as follows.
> - To remove device info, it waits for the backend path of the device
> to be removed.
> - It removes device info from domain info.
> - It saves domain info to the config.sxp of the managed domain.
>
This changes behavior between block-attach and block-detach. In
block-detach, the device is removed from store and unplugged from domain
if live. For block-attach, the operation fails if domain is inactive. If
domain is active, device is plugged but not persisted to store.
We need to agree on behavior when changing config of managed domains and
then set out on the (perhaps time consuming) path of realizing that
behavior.
Thoughts?
Jim
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Fix xm block/network-detach command
2007-08-03 20:48 [PATCH] Fix xm block/network-detach command Jim Fehlig
@ 2007-08-06 11:52 ` Masaki Kanno
2007-08-07 0:52 ` Jim Fehlig
1 sibling, 0 replies; 6+ messages in thread
From: Masaki Kanno @ 2007-08-06 11:52 UTC (permalink / raw)
To: Jim Fehlig; +Cc: xen-devel, mats
[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 4237 bytes --]
Hi Jim,
Mon Aug. 06 2007, Jim Fehlig wrote:
>Masaki Kanno wrote:
>> Hi,
>>
>> This patch fixes a few problem of xm block/network-detach command.
>>
>> At first, when I tested xm block/network-detach command to a inactive
>> managed domain, I saw the following error messages.
>>
>> # xm new /xen/vm1.conf
>> Using config file "/xen/vm1.conf".
>> # xm list --long vm1
>> (domain
>> <snip>
>> (device
>> (vif
>> (mac 00:16:3e:75:96:d8)
>> (uuid ebd29601-41ac-75de-87cd-2ae051fa8719)
>> )
>> )
>> (device
>> (vbd
>> (uuid 7572ae87-5706-217a-3fa5-f68496e147c1)
>> (bootable 1)
>> (driver paravirtualised)
>> (dev hda1)
>> (uname file:/xen/rhel4u2.root.img-vm1)
>> (mode w)
>> )
>> )
>> )
>> # xm block-detach vm1 hda1
>> Error: Device hda1 not connected
>> Usage: xm block-detach <Domain> <DevId> [-f|--force]
>>
>> Destroy a domain's virtual block device.
>> # xm network-detach vm1 0
>> Error: (22, 'Invalid argument, while reading None/device/vif/0/backend')
>> Usage: xm network-detach <Domain> <DevId> [-f|--force]
>>
>> Destroy a domain's virtual network device.
>>
>>
>> I was able to fix the problem of inactive managed domains by writing
>> a small patch.
>
>This brings up a broader question concerning managed domains. What is
>the behavior when changing config of a managed domain?
>
>a)
>- persist change to store and modify domain if live
>
>b)
>- explicitly change live config
>- explicitly change stored config
>
>Some of the xm commands support a). That would be behavior of
>block-detach with this patch.
>
>It appears Xen API supports b) given the *_live, plug, and unplug
>operations defined in the spec. I have noticed this to be the case for
>some resource types, but doubt it is consistent across all resource
>types - let alone both Xen API and legacy sxpr interfaces.
>
>IMO, since xen itself now supports managed domains it should be possible
>to independently change live and stored config. I should be able to feed
>a starving domain but have it revert to default (define by me) settings
>when reset. That said I think it will be considerable work, particularly
>testing, to ensure this behavior across all resource types and xend
>interfaces.
>
I also think the work to need an effort.
When we changed the resources configuration of domain by xm commands,
most resources configuration of domain is given to the reset domain
without change. AFAIK, only CPU affinity revert to default.
>> However, I found a other problem in xm block/network-
>> detach command when I tested xm block/network-detach command more.
>> The other problem is the same as the problem that Mats reported in
>> the following.
>>
>> http://lists.xensource.com/archives/html/xen-devel/2007-08/msg00040.html
>>
>
>That patch did not cause any problems with save.
>
>> This patch fixes the other problem as follows.
>> - To remove device info, it waits for the backend path of the device
>> to be removed.
>> - It removes device info from domain info.
>> - It saves domain info to the config.sxp of the managed domain.
>>
>
>This changes behavior between block-attach and block-detach. In
>block-detach, the device is removed from store and unplugged from domain
>if live. For block-attach, the operation fails if domain is inactive. If
>domain is active, device is plugged but not persisted to store.
>
I tried xm block/network-attach command with xen-unstable CS:15672.
Could you see the attached file "xm_attach.log" ?
If the domain is inactive, xm block/network-attach command succeed.
And the device info is saved into config.sxp.
If the domain is active, the device is plugged to the domain.
And the device info is saved into config.sxp.
My patch rolls back the proceeding of xm block/network-attach command.
Best regard,
Kan
>We need to agree on behavior when changing config of managed domains and
>then set out on the (perhaps time consuming) path of realizing that
>behavior.
>
>Thoughts?
>Jim
>
>
>_______________________________________________
>Xen-devel mailing list
>Xen-devel@lists.xensource.com
>http://lists.xensource.com/xen-devel
[-- Attachment #2: xm_attach.log --]
[-- Type: application/octet-stream, Size: 11063 bytes --]
# xm new /xen/vm1.conf
Using config file "/xen/vm1.conf".
# xm list --long vm1
(domain
(on_crash restart)
(uuid d9773b30-09fe-9e77-d43c-1c310064fde8)
(bootloader_args )
(vcpus 1)
(name vm1)
(on_poweroff destroy)
(on_reboot restart)
(bootloader )
(maxmem 256)
(memory 256)
(shadow_memory 0)
(cpu_weight 512)
(cpu_cap 100)
(features )
(on_xend_start ignore)
(on_xend_stop ignore)
(image
(linux
(kernel /boot/vmlinuz-2.6.18-xen)
(ramdisk /boot/initrd-2.6.18-xen.img.domU.1)
(args 'root=/dev/hda1 ro 3 consoel=tty1')
)
)
(status 0)
)
# cat /var/lib/xend/domains/d9773b30-09fe-9e77-d43c-1c310064fde8/config.sxp
(domain
(vcpus_params ())
(PV_args 'root=/dev/hda1 ro 3 consoel=tty1')
(PV_bootloader )
(VCPUs_live 1)
(actions_after_crash restart)
(uuid d9773b30-09fe-9e77-d43c-1c310064fde8)
(PV_ramdisk /boot/initrd-2.6.18-xen.img.domU.1)
(name_label vm1)
(VCPUs_at_startup 1)
(HVM_boot_params ())
(platform ())
(PV_kernel /boot/vmlinuz-2.6.18-xen)
(memory_static_min 0)
(HVM_boot_policy )
(VCPUs_max 1)
(memory_static_max 268435456)
(actions_after_shutdown destroy)
(memory_dynamic_max 268435456)
(is_a_template False)
(memory_dynamic_min 268435456)
(PV_bootloader_args )
(other_config ())
(actions_after_reboot restart)
(on_crash restart)
(uuid d9773b30-09fe-9e77-d43c-1c310064fde8)
(bootloader_args )
(vcpus 1)
(name vm1)
(on_poweroff destroy)
(on_reboot restart)
(bootloader )
(maxmem 256)
(memory 256)
(shadow_memory 0)
(vcpu_avail 1)
(cpu_weight 512)
(cpu_cap 100)
(features )
(on_xend_start ignore)
(on_xend_stop ignore)
(image
(linux
(kernel /boot/vmlinuz-2.6.18-xen)
(ramdisk /boot/initrd-2.6.18-xen.img.domU.1)
(args 'root=/dev/hda1 ro 3 consoel=tty1')
)
)
(status 0)
)
# xm block-attach vm1 file:/xen/root.img-vm1 hda1 w
# xm network-attach vm1
# xm list --long vm1
(domain
(on_crash restart)
(uuid d9773b30-09fe-9e77-d43c-1c310064fde8)
(bootloader_args )
(vcpus 1)
(name vm1)
(on_poweroff destroy)
(on_reboot restart)
(bootloader )
(maxmem 256)
(memory 256)
(shadow_memory 0)
(cpu_weight 512)
(cpu_cap 100)
(features )
(on_xend_start ignore)
(on_xend_stop ignore)
(image
(linux
(kernel /boot/vmlinuz-2.6.18-xen)
(ramdisk /boot/initrd-2.6.18-xen.img.domU.1)
(args 'root=/dev/hda1 ro 3 consoel=tty1')
)
)
(status 0)
(device
(vif
(mac 00:16:3e:75:1e:fe)
(uuid a8ab3150-59c2-7326-2f10-9d84c9368149)
)
)
(device
(vbd
(uuid b6017fa1-5688-117b-5b16-ff30226fd869)
(bootable 1)
(driver paravirtualised)
(dev hda1)
(uname file:/xen/root.img-vm1)
(mode w)
)
)
)
# cat /var/lib/xend/domains/d9773b30-09fe-9e77-d43c-1c310064fde8/config.sxp
(domain
(vcpus_params ())
(PV_args 'root=/dev/hda1 ro 3 consoel=tty1')
(PV_bootloader )
(VCPUs_live 1)
(actions_after_crash restart)
(uuid d9773b30-09fe-9e77-d43c-1c310064fde8)
(PV_ramdisk /boot/initrd-2.6.18-xen.img.domU.1)
(name_label vm1)
(VCPUs_at_startup 1)
(HVM_boot_params ())
(platform ())
(PV_kernel /boot/vmlinuz-2.6.18-xen)
(memory_static_min 0)
(HVM_boot_policy )
(VCPUs_max 1)
(memory_static_max 268435456)
(actions_after_shutdown destroy)
(memory_dynamic_max 268435456)
(is_a_template False)
(memory_dynamic_min 268435456)
(PV_bootloader_args )
(other_config ())
(actions_after_reboot restart)
(on_crash restart)
(uuid d9773b30-09fe-9e77-d43c-1c310064fde8)
(bootloader_args )
(vcpus 1)
(name vm1)
(on_poweroff destroy)
(on_reboot restart)
(bootloader )
(maxmem 256)
(memory 256)
(shadow_memory 0)
(vcpu_avail 1)
(cpu_weight 512)
(cpu_cap 100)
(features )
(on_xend_start ignore)
(on_xend_stop ignore)
(image
(linux
(kernel /boot/vmlinuz-2.6.18-xen)
(ramdisk /boot/initrd-2.6.18-xen.img.domU.1)
(args 'root=/dev/hda1 ro 3 consoel=tty1')
)
)
(status 0)
(device
(vif
(mac 00:16:3e:75:1e:fe)
(uuid a8ab3150-59c2-7326-2f10-9d84c9368149)
)
)
(device
(vbd
(uuid b6017fa1-5688-117b-5b16-ff30226fd869)
(bootable 1)
(driver paravirtualised)
(dev hda1)
(uname file:/xen/root.img-vm1)
(mode w)
)
)
)
# xm start vm1
# xm block-attach vm1 file:/xen/second.img hdb1 w
# xm network-attach vm1
# xm list --long vm1
(domain
(domid 1)
(on_crash restart)
(uuid d9773b30-09fe-9e77-d43c-1c310064fde8)
(bootloader_args )
(vcpus 1)
(name vm1)
(on_poweroff destroy)
(on_reboot restart)
(bootloader )
(maxmem 256)
(memory 256)
(shadow_memory 0)
(cpu_weight 512)
(cpu_cap 100)
(features )
(on_xend_start ignore)
(on_xend_stop ignore)
(start_time 1186399403.1)
(cpu_time 70.681147403)
(online_vcpus 1)
(image
(linux
(kernel /boot/vmlinuz-2.6.18-xen)
(ramdisk /boot/initrd-2.6.18-xen.img.domU.1)
(args 'root=/dev/hda1 ro 3 consoel=tty1')
(rtc_timeoffset 0)
(notes
(HV_START_LOW 4118806528)
(FEATURES
'writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel'
)
(VIRT_BASE 3221225472)
(GUEST_VERSION 2.6)
(PADDR_OFFSET 3221225472)
(GUEST_OS linux)
(HYPERCALL_PAGE 3222278144)
(LOADER generic)
(SUSPEND_CANCEL 1)
(PAE_MODE yes)
(ENTRY 3222274048)
(XEN_VERSION xen-3.0)
)
)
)
(status 2)
(state r-----)
(store_mfn 120005)
(console_mfn 120004)
(device
(vif
(mac 00:16:3e:75:1e:fe)
(script vif-bridge)
(type netfront)
(uuid a8ab3150-59c2-7326-2f10-9d84c9368149)
(backend 0)
)
)
(device
(vif
(mac 00:16:3e:7e:b8:35)
(script vif-bridge)
(type netfront)
(uuid a3157965-92f2-dec2-17a5-c6e84b45b3a8)
(backend 0)
)
)
(device
(vbd
(uname file:/xen/root.img-vm1)
(uuid b6017fa1-5688-117b-5b16-ff30226fd869)
(mode w)
(dev hda1:disk)
(backend 0)
(bootable 1)
)
)
(device
(vbd
(uname file:/xen/second.img)
(uuid bd2a234c-53e6-e9e5-f7e2-29b1815cee76)
(mode w)
(dev hdb1:disk)
(backend 0)
(bootable 0)
)
)
(device
(console
(protocol vt100)
(location 2)
(uuid b616112f-af93-9ab4-0d34-a4574105bf65)
)
)
)
# cat /var/lib/xend/domains/d9773b30-09fe-9e77-d43c-1c310064fde8/config.sxp
(domain
(domid 1)
(vcpus_params ())
(PV_args 'root=/dev/hda1 ro 3 consoel=tty1')
(PV_bootloader )
(VCPUs_live 1)
(actions_after_crash restart)
(uuid d9773b30-09fe-9e77-d43c-1c310064fde8)
(PV_ramdisk /boot/initrd-2.6.18-xen.img.domU.1)
(name_label vm1)
(VCPUs_at_startup 1)
(HVM_boot_params ())
(platform ((rtc_timeoffset 0)))
(PV_kernel /boot/vmlinuz-2.6.18-xen)
(memory_static_min 0)
(HVM_boot_policy )
(VCPUs_max 1)
(memory_static_max 268435456)
(actions_after_shutdown destroy)
(memory_dynamic_max 268435456)
(is_a_template False)
(memory_dynamic_min 268435456)
(PV_bootloader_args )
(other_config ())
(actions_after_reboot restart)
(on_crash restart)
(uuid d9773b30-09fe-9e77-d43c-1c310064fde8)
(bootloader_args )
(vcpus 1)
(name vm1)
(on_poweroff destroy)
(on_reboot restart)
(bootloader )
(maxmem 256)
(memory 256)
(shadow_memory 0)
(vcpu_avail 1)
(cpu_weight 512)
(cpu_cap 100)
(features )
(on_xend_start ignore)
(on_xend_stop ignore)
(start_time 1186399403.1)
(cpu_time 63.616123205)
(online_vcpus 1)
(image
(linux
(kernel /boot/vmlinuz-2.6.18-xen)
(ramdisk /boot/initrd-2.6.18-xen.img.domU.1)
(args 'root=/dev/hda1 ro 3 consoel=tty1')
(rtc_timeoffset 0)
(notes
(HV_START_LOW 4118806528)
(FEATURES
'writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel'
)
(VIRT_BASE 3221225472)
(GUEST_VERSION 2.6)
(PADDR_OFFSET 3221225472)
(GUEST_OS linux)
(HYPERCALL_PAGE 3222278144)
(LOADER generic)
(SUSPEND_CANCEL 1)
(PAE_MODE yes)
(ENTRY 3222274048)
(XEN_VERSION xen-3.0)
)
)
)
(status 2)
(state r-----)
(store_mfn 120005)
(console_mfn 120004)
(device
(vif
(mac 00:16:3e:75:1e:fe)
(script vif-bridge)
(type netfront)
(uuid a8ab3150-59c2-7326-2f10-9d84c9368149)
(backend 0)
)
)
(device
(vif
(mac 00:16:3e:7e:b8:35)
(script vif-bridge)
(type netfront)
(uuid a3157965-92f2-dec2-17a5-c6e84b45b3a8)
(backend 0)
)
)
(device
(vbd
(uname file:/xen/root.img-vm1)
(uuid b6017fa1-5688-117b-5b16-ff30226fd869)
(mode w)
(dev hda1:disk)
(backend 0)
(bootable 1)
)
)
(device
(vbd
(uname file:/xen/second.img)
(uuid bd2a234c-53e6-e9e5-f7e2-29b1815cee76)
(mode w)
(dev hdb1:disk)
(backend 0)
(bootable 0)
)
)
(device
(console
(protocol vt100)
(location 2)
(uuid b616112f-af93-9ab4-0d34-a4574105bf65)
)
)
)
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Fix xm block/network-detach command
2007-08-03 20:48 [PATCH] Fix xm block/network-detach command Jim Fehlig
2007-08-06 11:52 ` Masaki Kanno
@ 2007-08-07 0:52 ` Jim Fehlig
2007-08-07 10:38 ` Masaki Kanno
1 sibling, 1 reply; 6+ messages in thread
From: Jim Fehlig @ 2007-08-07 0:52 UTC (permalink / raw)
To: Masaki Kanno; +Cc: xen-devel, mats
Masaki Kanno wrote:
<snip>
>> IMO, since xen itself now supports managed domains it should be possible
>> to independently change live and stored config. I should be able to feed
>> a starving domain but have it revert to default (define by me) settings
>> when reset. That said I think it will be considerable work, particularly
>> testing, to ensure this behavior across all resource types and xend
>> interfaces.
>>
>>
>
> I also think the work to need an effort.
> When we changed the resources configuration of domain by xm commands,
> most resources configuration of domain is given to the reset domain
> without change. AFAIK, only CPU affinity revert to default.
>
Right.
>> This changes behavior between block-attach and block-detach. In
>> block-detach, the device is removed from store and unplugged from domain
>> if live. For block-attach, the operation fails if domain is inactive. If
>> domain is active, device is plugged but not persisted to store.
>>
>>
>
> I tried xm block/network-attach command with xen-unstable CS:15672.
>
Yep, sorry. I tested this patch on a 3.1.0-based system missing your
earlier patch
http://xenbits2.xensource.com/xen-unstable.hg?rev/3196b63a7301
With both patches, block-[attach|detach] behave symmetrically. I found
no problems testing your patch on c/s 15672.
A comment about the patch:
+
+ def convertToDeviceNumber(self, devid):
+ try:
+ dev = int(devid)
+ except ValueError:
+ # devid is not a number but a string containing either
+ # device name (e.g. xvda or xvda:disk) or
+ # device_type/device_id (e.g. vbd/51728)
+ dev = type(devid) is str and devid.split('/')[-1] or None
+ if dev == None:
+ return None
+ try:
+ dev = int(dev)
+ except ValueError:
+ dev = dev.split(':')[0]
+ dev = blkdev_name_to_number(dev)
+ return dev
Can this be pushed into the DevController? Seems like the individual
device controllers would be best equipped to determine validity of a
deviceid. That's what I was trying to do with this patch
http://lists.xensource.com/archives/html/xen-devel/2007-08/msg00038.html
which I see is now in the staging tree as c/s 15689. BTW, there a two
xml files included in that c/s that were not part of the patch I
submitted :-).
Regards,
Jim
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Fix xm block/network-detach command
2007-08-07 0:52 ` Jim Fehlig
@ 2007-08-07 10:38 ` Masaki Kanno
2007-08-07 10:40 ` Keir Fraser
0 siblings, 1 reply; 6+ messages in thread
From: Masaki Kanno @ 2007-08-07 10:38 UTC (permalink / raw)
To: Jim Fehlig; +Cc: xen-devel, mats
Hi Jim,
Tue Aug. 07 2007, Jim Fehlig wrote:
<snip>
>A comment about the patch:
>
>+
>+ def convertToDeviceNumber(self, devid):
>+ try:
>+ dev = int(devid)
>+ except ValueError:
>+ # devid is not a number but a string containing either
>+ # device name (e.g. xvda or xvda:disk) or
>+ # device_type/device_id (e.g. vbd/51728)
>+ dev = type(devid) is str and devid.split('/')[-1] or None
>+ if dev == None:
>+ return None
>+ try:
>+ dev = int(dev)
>+ except ValueError:
>+ dev = dev.split(':')[0]
>+ dev = blkdev_name_to_number(dev)
>+ return dev
>
>Can this be pushed into the DevController? Seems like the individual
>device controllers would be best equipped to determine validity of a
>deviceid. That's what I was trying to do with this patch
I believe that I can do it.
>http://lists.xensource.com/archives/html/xen-devel/2007-08/msg00038.html
>
>which I see is now in the staging tree as c/s 15689. BTW, there a two
>xml files included in that c/s that were not part of the patch I
>submitted :-).
Maybe they are patches for CS:15688.
Best regards,
Kan
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Fix xm block/network-detach command
@ 2007-08-03 5:20 Masaki Kanno
0 siblings, 0 replies; 6+ messages in thread
From: Masaki Kanno @ 2007-08-03 5:20 UTC (permalink / raw)
To: xen-devel; +Cc: jfehlig, mats
[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 1735 bytes --]
Hi,
This patch fixes a few problem of xm block/network-detach command.
At first, when I tested xm block/network-detach command to a inactive
managed domain, I saw the following error messages.
# xm new /xen/vm1.conf
Using config file "/xen/vm1.conf".
# xm list --long vm1
(domain
<snip>
(device
(vif
(mac 00:16:3e:75:96:d8)
(uuid ebd29601-41ac-75de-87cd-2ae051fa8719)
)
)
(device
(vbd
(uuid 7572ae87-5706-217a-3fa5-f68496e147c1)
(bootable 1)
(driver paravirtualised)
(dev hda1)
(uname file:/xen/rhel4u2.root.img-vm1)
(mode w)
)
)
)
# xm block-detach vm1 hda1
Error: Device hda1 not connected
Usage: xm block-detach <Domain> <DevId> [-f|--force]
Destroy a domain's virtual block device.
# xm network-detach vm1 0
Error: (22, 'Invalid argument, while reading None/device/vif/0/backend')
Usage: xm network-detach <Domain> <DevId> [-f|--force]
Destroy a domain's virtual network device.
I was able to fix the problem of inactive managed domains by writing
a small patch. However, I found a other problem in xm block/network-
detach command when I tested xm block/network-detach command more.
The other problem is the same as the problem that Mats reported in
the following.
http://lists.xensource.com/archives/html/xen-devel/2007-08/msg00040.html
This patch fixes the other problem as follows.
- To remove device info, it waits for the backend path of the device
to be removed.
- It removes device info from domain info.
- It saves domain info to the config.sxp of the managed domain.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Best regards,
Kan
[-- Attachment #2: xm_block_detach.patch --]
[-- Type: application/octet-stream, Size: 8892 bytes --]
diff -r 88bb0d305308 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Wed Aug 01 15:47:54 2007 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py Fri Aug 03 14:08:46 2007 +0900
@@ -36,6 +36,7 @@ import xen.lowlevel.xc
import xen.lowlevel.xc
from xen.util import asserts
from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
+from xen.util.blkif import blkdev_name_to_number
from xen.util import security
from xen.xend import balloon, sxp, uuid, image, arch, osdep
@@ -558,19 +559,65 @@ class XendDomainInfo:
for devclass in XendDevices.valid_devices():
self.getDeviceController(devclass).waitForDevices()
- def destroyDevice(self, deviceClass, devid, force = False):
- try:
- dev = int(devid)
- except ValueError:
- # devid is not a number but a string containing either device
- # name (e.g. xvda) or device_type/device_id (e.g. vbd/51728)
- dev = type(devid) is str and devid.split('/')[-1] or None
- if dev == None:
- log.debug("Could not find the device %s", devid)
- return None
-
- log.debug("dev = %s", dev)
- return self.getDeviceController(deviceClass).destroyDevice(dev, force)
+ def destroyDevice(self, deviceClass, devid, force = False, rm_cfg = False):
+ dev = self.convertToDeviceNumber(devid)
+ if dev == None:
+ log.debug("Could not find the device %s", devid)
+ return None
+
+ log.debug("XendDomainInfo.destroyDevice: deviceClass = %s, device = %s(%d)",
+ deviceClass, devid, dev)
+
+ if rm_cfg:
+ # Save current sxprs. A device number and a backend
+ # path are needed to remove its configuration but sxprs
+ # do not have those after calling destroyDevice.
+ sxprs = self.getDeviceSxprs(deviceClass)
+
+ rc = None
+ if self.domid is not None:
+ rc = self.getDeviceController(deviceClass).destroyDevice(dev, force)
+ if not force and rm_cfg:
+ # The backend path, other than the device itself,
+ # has to be passed because its accompanied frontend
+ # path may be void until its removal is actually
+ # issued. It is probable because destroyDevice is
+ # issued first.
+ for dev_num, dev_info in sxprs:
+ dev_num = int(dev_num)
+ if dev_num == dev:
+ for x in dev_info:
+ if x[0] == 'backend':
+ backend = x[1]
+ break
+ break
+ self._waitForDevice_destroy(deviceClass, dev, backend)
+
+ if rm_cfg:
+ if deviceClass == 'vif':
+ if self.domid is not None:
+ for dev_num, dev_info in sxprs:
+ dev_num = int(dev_num)
+ if dev_num == dev:
+ for x in dev_info:
+ if x[0] == 'mac':
+ mac = x[1]
+ break
+ break
+ dev_info = self.getDeviceInfo_vif(mac)
+ else:
+ _, dev_info = sxprs[dev]
+ else: # 'vbd' or 'tap'
+ dev_info = self.getDeviceInfo_vbd(dev)
+ if dev_info is None:
+ return rc
+
+ dev_uuid = sxp.child_value(dev_info, 'uuid')
+ del self.info['devices'][dev_uuid]
+ self.info['%s_refs' % deviceClass].remove(dev_uuid)
+ xen.xend.XendDomain.instance().managed_config_save(self)
+
+ return rc
def getDeviceSxprs(self, deviceClass):
if self._stateGet() in (DOM_STATE_RUNNING, DOM_STATE_PAUSED):
@@ -1331,6 +1378,10 @@ class XendDomainInfo:
deviceClass, config = self.info['devices'].get(dev_uuid)
self._waitForDevice(deviceClass, config['devid'])
+ def _waitForDevice_destroy(self, deviceClass, devid, backpath):
+ return self.getDeviceController(deviceClass).waitForDevice_destroy(
+ devid, backpath)
+
def _reconfigureDevice(self, deviceClass, devid, devconfig):
return self.getDeviceController(deviceClass).reconfigureDevice(
devid, devconfig)
@@ -1390,6 +1441,39 @@ class XendDomainInfo:
self._deviceControllers[name] = devController
return self._deviceControllers[name]
+
+ def convertToDeviceNumber(self, devid):
+ try:
+ dev = int(devid)
+ except ValueError:
+ # devid is not a number but a string containing either
+ # device name (e.g. xvda or xvda:disk) or
+ # device_type/device_id (e.g. vbd/51728)
+ dev = type(devid) is str and devid.split('/')[-1] or None
+ if dev == None:
+ return None
+ try:
+ dev = int(dev)
+ except ValueError:
+ dev = dev.split(':')[0]
+ dev = blkdev_name_to_number(dev)
+ return dev
+
+ def getDeviceInfo_vif(self, mac):
+ for dev_type, dev_info in self.info.all_devices_sxpr():
+ if dev_type != 'vif':
+ continue
+ if mac == sxp.child_value(dev_info, 'mac'):
+ return dev_info
+
+ def getDeviceInfo_vbd(self, devid):
+ for dev_type, dev_info in self.info.all_devices_sxpr():
+ if dev_type != 'vbd' and dev_type != 'tap':
+ continue
+ dev = sxp.child_value(dev_info, 'dev')
+ dev = self.convertToDeviceNumber(dev)
+ if devid == dev:
+ return dev_info
#
# Migration functions (public)
diff -r 88bb0d305308 tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py Wed Aug 01 15:47:54 2007 +0100
+++ b/tools/python/xen/xend/server/DevController.py Thu Aug 02 08:46:56 2007 +0900
@@ -28,17 +28,19 @@ from xen.xend.xenstore.xswatch import xs
import os
-DEVICE_CREATE_TIMEOUT = 100
+DEVICE_CREATE_TIMEOUT = 100
+DEVICE_DESTROY_TIMEOUT = 100
HOTPLUG_STATUS_NODE = "hotplug-status"
HOTPLUG_ERROR_NODE = "hotplug-error"
HOTPLUG_STATUS_ERROR = "error"
HOTPLUG_STATUS_BUSY = "busy"
-Connected = 1
-Error = 2
-Missing = 3
-Timeout = 4
-Busy = 5
+Connected = 1
+Error = 2
+Missing = 3
+Timeout = 4
+Busy = 5
+Disconnected = 6
xenbusState = {
'Unknown' : 0,
@@ -184,6 +186,18 @@ class DevController:
raise VmError("Device %s (%s) could not be connected.\n%s" %
(devid, self.deviceClass, err))
+
+ def waitForDevice_destroy(self, devid, backpath):
+ log.debug("Waiting for %s - destroyDevice.", devid)
+
+ if not self.hotplug:
+ return
+
+ status = self.waitForBackend_destroy(backpath)
+
+ if status == Timeout:
+ raise VmError("Device %s (%s) could not be disconnected. " %
+ (devid, self.deviceClass))
def reconfigureDevice(self, devid, config):
@@ -508,6 +522,19 @@ class DevController:
return (Missing, None)
+ def waitForBackend_destroy(self, backpath):
+
+ statusPath = backpath + '/' + HOTPLUG_STATUS_NODE
+ ev = Event()
+ result = { 'status': Timeout }
+
+ xswatch(statusPath, deviceDestroyCallback, ev, result)
+
+ ev.wait(DEVICE_DESTROY_TIMEOUT)
+
+ return result['status']
+
+
def backendPath(self, backdom, devid):
"""Construct backend path given the backend domain and device id.
@@ -556,3 +583,19 @@ def hotplugStatusCallback(statusPath, ev
ev.set()
return 0
+
+
+def deviceDestroyCallback(statusPath, ev, result):
+ log.debug("deviceDestroyCallback %s.", statusPath)
+
+ status = xstransact.Read(statusPath)
+
+ if status is None:
+ result['status'] = Disconnected
+ else:
+ return 1
+
+ log.debug("deviceDestroyCallback %d.", result['status'])
+
+ ev.set()
+ return 0
diff -r 88bb0d305308 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Wed Aug 01 15:47:54 2007 +0100
+++ b/tools/python/xen/xm/main.py Tue Jul 31 09:28:11 2007 +0900
@@ -2185,6 +2185,7 @@ def xm_network_attach(args):
def detach(args, deviceClass):
+ rm_cfg = True
dom = args[0]
dev = args[1]
try:
@@ -2195,7 +2196,7 @@ def detach(args, deviceClass):
except IndexError:
force = None
- server.xend.domain.destroyDevice(dom, deviceClass, dev, force)
+ server.xend.domain.destroyDevice(dom, deviceClass, dev, force, rm_cfg)
def xm_block_detach(args):
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-08-07 10:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-03 20:48 [PATCH] Fix xm block/network-detach command Jim Fehlig
2007-08-06 11:52 ` Masaki Kanno
2007-08-07 0:52 ` Jim Fehlig
2007-08-07 10:38 ` Masaki Kanno
2007-08-07 10:40 ` Keir Fraser
-- strict thread matches above, loose matches on Subject: below --
2007-08-03 5:20 Masaki Kanno
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.