Skip to contentSkip to conversation

pci hotplug in xcp

DISCUSSION Ritu kaur 5 participants 15 messages Apr 6, 2010 – Apr 8, 2010 1 message not in the archive

lore
Share & tools
lore

Ritu kaur

author
#0 lore raw

Hello!!!

Does pci hotplug work with pci passthrough in xcp? Currently, I have 2 VMs and do the following to transfer pci device from one domU to another

1. shutdown vm1
2. shutdown vm2
2. in dom0, xe vm-param-set uuid=<vm1-uuid> other-config:pci=""
3. in dom0, xe vm-param-set uuid=<vm2-uuid> other-config:pci=<pci-dev>
4. start vm1
5. start vm2

I want to avoid VM shutdown/start. is there a way to hot unplug from vm1 and hot plug into vm2 in xcp?

Thanks

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Hi,

Currently the only way to hotplug is via the 'xenops' commandline tool. Try:

# /opt/xensource/debug/xenops plug_pci -domid .. -pci .. -devid 0
And similarly for unplug_pci

Cheers,
Dave

From: [email protected] [mailto:[email protected]] On Behalf Of Ritu kaur
Sent: 06 April 2010 18:04
To: [email protected]
Subject: [Xen-devel] pci hotplug in xcp

Hello!!!

Does pci hotplug work with pci passthrough in xcp? Currently, I have 2 VMs and do the following to transfer pci device from one domU to another

1. shutdown vm1
2. shutdown vm2
2. in dom0, xe vm-param-set uuid=<vm1-uuid> other-config:pci=""
3. in dom0, xe vm-param-set uuid=<vm2-uuid> other-config:pci=<pci-dev>
4. start vm1
5. start vm2

I want to avoid VM shutdown/start. is there a way to hot unplug from vm1 and hot plug into vm2 in xcp?

Thanks

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

A message that is not in the archive (sent off-list or not yet received): 81A73678E76EA642801C8F2E4823AD21565E5542A8-aFusIB7tbcLeU4JHVX8hdHnr0TU713UqXqFh9Ls21Oc@public.gmane.org

#3 lore raw
Quoted 6 lines

Currently the only way to hotplug is via the 'xenops' commandline tool. Try:

# /opt/xensource/debug/xenops plug_pci -domid .. -pci .. -devid 0

And similarly for unplug_pci

It would be a good 'starter' project for someone to add hotplug support to the API -- I'm sure there are folk on the list that would be happy to help with the design. Any takers?
Thanks,
Ian

author
#5 lore raw

xl pci-attach doesn't seem to work unless vm is rebooted. Steps followed

1. modprobe pciback on dom0
2. execute xl pci-attach 1 0000:08:01.0, following msgs seen... [-1] libxl.c:2061:libxl_device_pci_add: xc_assign_device failed: Success
[3] libxl.c:1763:libxl_create_pci_backend: Creating pci backend

3. xl pci-list 1
VFn domain bus slot func
0x00 0x0000 0x08 0x01 0x0

4. login into vm, lspci doesn't show anything.

5. vm:~# lspci
vm:~#

6. reboot vm, do lspci again it works.

vm:~# lspci
00:00.0 Ethernet controller: Device feed:face

I want to avoid vm reboot?

Thanks

Quoted 7 lines · Stefano Stabellini
Quoted 4 lines · Dave Scott

Hi,

Currently the only way to hotplug is via the ‘xenops’ commandline tool.

Try:

Quoted 1 line
Quoted 8 lines
Quoted 3 lines
# /opt/xensource/debug/xenops plug_pci –domid .. –pci .. –devid 0

And similarly for unplug_pci

xl is also present is XCP so the following should also work:

xl pci-attach <domid> <BDF>

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw
Quoted 3 lines · Ritu kaur

xl pci-attach doesn't seem to work unless vm is rebooted. Steps followed

1. modprobe pciback on dom0

did you bind the device to pciback before executing "xl pci-attach"? xl doesn't do it for you.
Beside you need to add -priv to the qemu command line options and to do that you need to edit /opt/xensource/libexec/qemu-dm-wrapper for example adding

qemu_args.append("-priv")

right after

qemu_args.append("pty")

sorry for not mentioning this before :)

#7 lore raw
Quoted 11 lines · Ritu kaur
Quoted 3 lines

xl pci-attach doesn't seem to work unless vm is rebooted. Steps followed

1. modprobe pciback on dom0

did you bind the device to pciback before executing "xl pci-attach"? xl doesn't do it for you.
Beside you need to add -priv to the qemu command line options and to do that you need to edit /opt/xensource/libexec/qemu-dm-wrapper for example adding

Quoted 7 lines

qemu_args.append("-priv")

right after

qemu_args.append("pty")

sorry for not mentioning this before :)

If you want to use hotplug rather than static assignment, you should make sure that the guest has a "pci" key (even an empty one) as this causes xapi to take care of setting the guest up for PCI passthrough, so you don't have to manually edit anything. E.g.:
xe vm-param-set other-config:pci="" uuid=$VMUUID

Ian

author
#8 lore raw

Thanks Ian. I have other-config:pci="" set in both my VM's. Once I have pci device binding issue solved I will try this out.

Thanks

Quoted 28 lines · Ian Pratt
Quoted 2 lines · Ritu kaur
Quoted 1 line

xl pci-attach doesn't seem to work unless vm is rebooted. Steps

followed

Quoted 9 lines
Quoted 2 lines

1. modprobe pciback on dom0

did you bind the device to pciback before executing "xl pci-attach"? xl doesn't do it for you.
Beside you need to add -priv to the qemu command line options and to do that you need to edit /opt/xensource/libexec/qemu-dm-wrapper for example adding

Quoted 7 lines

qemu_args.append("-priv")

right after

qemu_args.append("pty")

sorry for not mentioning this before :)

If you want to use hotplug rather than static assignment, you should make sure that the guest has a "pci" key (even an empty one) as this causes xapi to take care of setting the guest up for PCI passthrough, so you don't have to manually edit anything. E.g.:
xe vm-param-set other-config:pci="" uuid=$VMUUID

Quoted 3 lines

Ian

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#9 lore raw
In reply to Stefano Stabellini

Thanks Stefano.

I am having problems binding device to pciback(this is from day1). Driver for this device is not loaded in dom0 so this device is not bound to any driver.

#echo $pcidev
0000:08:01.0

# echo -n $pcidev > /sys/bus/pci/drivers/pciback/bind
-bash: echo: write error: No such device

ls -l /sys/bus/pci/drivers/pciback/bind
--w------- 1 root root 4096 Apr 8 07:40 /sys/bus/pci/drivers/pciback/bind

Any inputs?

Thanks

Quoted 11 lines · Stefano Stabellini
Quoted 3 lines · Ritu kaur

xl pci-attach doesn't seem to work unless vm is rebooted. Steps followed

1. modprobe pciback on dom0

did you bind the device to pciback before executing "xl pci-attach"? xl doesn't do it for you.
Beside you need to add -priv to the qemu command line options and to do that you need to edit /opt/xensource/libexec/qemu-dm-wrapper for example adding

Quoted 9 lines

qemu_args.append("-priv")

right after

qemu_args.append("pty")

sorry for not mentioning this before :)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#10 lore raw
Quoted 8 lines · Ritu kaur

Thanks Stefano.

I am having problems binding device to pciback(this is from day1). Driver for this device is not loaded in dom0 so this device is not bound to any driver.

#echo $pcidev
0000:08:01.0

Quoted 8 lines
# echo -n $pcidev > /sys/bus/pci/drivers/pciback/bind
-bash: echo: write error: No such device

ls -l /sys/bus/pci/drivers/pciback/bind
--w------- 1 root root 4096 Apr  8 07:40 /sys/bus/pci/drivers/pciback/bind

Any inputs?

you need to do this:

echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/new_slot echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/bind

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#11 lore raw

Thanks Stefano. It did work fine first time however subsequent attach/detach doesn't work. What I did

1. (VM has other-config:pci="" as suggested by Ian)

2. modprobe pciback

3. echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/new_slot echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/bind

4. start VM

5. xl pci-attach 1 0000:08:01.0(Cross checked in VM can see device via lspci)

6. xl pci-detach 1 0000:08:01.0(Cross checked in VM, no device via lspci)

7. xl pci-attach 1 0000:08:01.0(lspci in VM doesn't list the device)

8. xl pci-list 1 in dom0 lists the device

9. When try to detach I get
xl pci-detach 1 0000:08:01.0

[0] libxl_device.c:444:libxl_wait_for_backend: Backend /local/domain/0/backend/pci/1/0 not ready
[3] libxl.c:1881:libxl_device_pci_remove_xenstore: pci backend at /local/domain/0/backend/pci/1/0 is not ready
[-1] libxl.c:2151:libxl_device_pci_remove: xc_deassign_device failed:
Success

dmesg in dom0 has

...
pciback: vpci: 0000:08:01.0: assign to virtual slot 0
pciback: vpci: 0000:08:01.0: assign to virtual slot 0

nothing related to detach. Do I need to run any other command prior to subsequent attach?

Thanks

Quoted 17 lines · Stefano Stabellini
Quoted 3 lines · Ritu kaur

Thanks Stefano.

I am having problems binding device to pciback(this is from day1). Driver

for this device is not loaded in dom0 so this

Quoted 10 lines

device is not bound to any driver.

#echo $pcidev
0000:08:01.0

# echo -n $pcidev > /sys/bus/pci/drivers/pciback/bind
-bash: echo: write error: No such device

ls -l /sys/bus/pci/drivers/pciback/bind
--w------- 1 root root 4096 Apr 8 07:40

/sys/bus/pci/drivers/pciback/bind

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Any inputs?

you need to do this:

echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/new_slot echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/bind

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#12 lore raw

Please post the qemu logs (in XCP they go to syslog, so /var/log/messages and /tmp/qemu.$domid), they'll probably reveal an error.
What is the guest operating system? If it is Linux make sure acpiphp is loaded.

Quoted 55 lines · Ritu kaur

Thanks Stefano. It did work fine first time however subsequent attach/detach doesn't work. What I did

1. (VM has other-config:pci="" as suggested by Ian)

2. modprobe pciback

3. echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/new_slot echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/bind

4. start VM

5. xl pci-attach 1 0000:08:01.0(Cross checked in VM can see device via lspci)

6. xl pci-detach 1 0000:08:01.0(Cross checked in VM, no device via lspci)

7. xl pci-attach 1 0000:08:01.0(lspci in VM doesn't list the device)

8. xl pci-list 1 in dom0 lists the device

9. When try to detach I get
xl pci-detach 1 0000:08:01.0

[0] libxl_device.c:444:libxl_wait_for_backend: Backend /local/domain/0/backend/pci/1/0 not ready
[3] libxl.c:1881:libxl_device_pci_remove_xenstore: pci backend at /local/domain/0/backend/pci/1/0 is not ready [-1] libxl.c:2151:libxl_device_pci_remove: xc_deassign_device failed: Success

dmesg in dom0 has

...
pciback: vpci: 0000:08:01.0: assign to virtual slot 0
pciback: vpci: 0000:08:01.0: assign to virtual slot 0

nothing related to detach. Do I need to run any other command prior to subsequent attach?

Thanks

On Thu, Apr 8, 2010 at 7:47 AM, Stefano Stabellini <[email protected]> wrote:
On Thu, 8 Apr 2010, Ritu kaur wrote:
> Thanks Stefano.
>
> I am having problems binding device to pciback(this is from day1). Driver for this device is not loaded in dom0 so this
> device is not bound to any driver.
>
> #echo $pcidev
> 0000:08:01.0
>
> # echo -n $pcidev > /sys/bus/pci/drivers/pciback/bind
> -bash: echo: write error: No such device
>
> ls -l /sys/bus/pci/drivers/pciback/bind
> --w------- 1 root root 4096 Apr  8 07:40 /sys/bus/pci/drivers/pciback/bind
>
> Any inputs?
>

Quoted 8 lines

you need to do this:

echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/new_slot echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/bind

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#13 lore raw

1. Guest OS is Debian Lenny 5.0(with 2.6.32.9 kernel from xen.org)

2. acpiphp module is loaded in guest OS

3. in my xcp dom0 I do not see /tmp/qemu.<domid> files, what I have

# ls -l
total 8
drwx------ 3 root root 4096 Mar 11 10:21 lvm
-rw-r--r-- 1 root root    0 Apr  8 09:25 master
-rw-r--r-- 1 root root  848 Apr  8 09:27 xenguest.log

xenguest.log doesn't reveal anything.

4. attached /var/log/messages.

Thanks

Quoted 67 lines · Stefano Stabellini

Please post the qemu logs (in XCP they go to syslog, so /var/log/messages and /tmp/qemu.$domid), they'll probably reveal an error.
What is the guest operating system? If it is Linux make sure acpiphp is loaded.

Quoted 1 line · Ritu kaur

Thanks Stefano. It did work fine first time however subsequent

attach/detach doesn't work. What I did

Quoted 6 lines

1. (VM has other-config:pci="" as suggested by Ian)

2. modprobe pciback

3. echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/new_slot echo -n

"$pcidev" > /sys/bus/pci/drivers/pciback/bind

Quoted 4 lines

4. start VM

5. xl pci-attach 1 0000:08:01.0(Cross checked in VM can see device via

lspci)

Quoted 11 lines

6. xl pci-detach 1 0000:08:01.0(Cross checked in VM, no device via lspci)

7. xl pci-attach 1 0000:08:01.0(lspci in VM doesn't list the device)

8. xl pci-list 1 in dom0 lists the device

9. When try to detach I get
xl pci-detach 1 0000:08:01.0

[0] libxl_device.c:444:libxl_wait_for_backend: Backend

/local/domain/0/backend/pci/1/0 not ready

Quoted 1 line

[3] libxl.c:1881:libxl_device_pci_remove_xenstore: pci backend at

/local/domain/0/backend/pci/1/0 is not ready

Quoted 1 line

[-1] libxl.c:2151:libxl_device_pci_remove: xc_deassign_device failed:

Success

Quoted 8 lines

dmesg in dom0 has

...
pciback: vpci: 0000:08:01.0: assign to virtual slot 0
pciback: vpci: 0000:08:01.0: assign to virtual slot 0

nothing related to detach. Do I need to run any other command prior to

subsequent attach?

Quoted 4 lines

Thanks

On Thu, Apr 8, 2010 at 7:47 AM, Stefano Stabellini <

Quoted 4 lines · [email protected]> wrote:

On Thu, 8 Apr 2010, Ritu kaur wrote:
> Thanks Stefano.
>
> I am having problems binding device to pciback(this is from

day1). Driver for this device is not loaded in

Quoted 11 lines

dom0 so this
> device is not bound to any driver.
>
> #echo $pcidev
> 0000:08:01.0
>
> # echo -n $pcidev > /sys/bus/pci/drivers/pciback/bind > -bash: echo: write error: No such device
>
> ls -l /sys/bus/pci/drivers/pciback/bind
> --w------- 1 root root 4096 Apr 8 07:40

Quoted 14 lines

/sys/bus/pci/drivers/pciback/bind

Quoted 12 lines
      >
      > Any inputs?
      >

you need to do this:

echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/new_slot echo -n "$pcidev" > /sys/bus/pci/drivers/pciback/bind

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#14 lore raw
Quoted 10 lines · Ritu kaur

3. in my xcp dom0 I do not see /tmp/qemu.<domid> files, what I have

# ls -l
total 8
drwx------ 3 root root 4096 Mar 11 10:21 lvm
(quoted diff) +0 -2
-rw-r--r-- 1 root root    0 Apr  8 09:25 master
-rw-r--r-- 1 root root  848 Apr  8 09:27 xenguest.log

xenguest.log doesn't reveal anything.

they are deleted when the VM shut down

Quoted 2 lines

4. attached /var/log/messages.

unfortunately the interesting stuff was already rotated somewhere else

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#15 lore raw

Guest VM's are still running, they are not shutdown. I am just doing multiple attach/detach sequence.

Thanks

Quoted 15 lines · Stefano Stabellini
Quoted 10 lines · Ritu kaur

3. in my xcp dom0 I do not see /tmp/qemu.<domid> files, what I have

# ls -l
total 8
drwx------ 3 root root 4096 Mar 11 10:21 lvm
(quoted diff) +0 -2
-rw-r--r-- 1 root root    0 Apr  8 09:25 master
-rw-r--r-- 1 root root  848 Apr  8 09:27 xenguest.log

xenguest.log doesn't reveal anything.

they are deleted when the VM shut down

Quoted 7 lines
Quoted 2 lines

4. attached /var/log/messages.

unfortunately the interesting stuff was already rotated somewhere else

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel