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

Re: [libvirt] Node devices?



Ed Swierk wrote:
After staring at the code implementing node devices in libvirt, I have
decided that they're really neat, but I have no idea what they are for
or how to use them.

Reading the API docs and searching libvir-list didn't help much, and
the user documentation (http://libvirt.org/archnode.html and
http://libvirt.org/formatnode.html) is a bit, err, high-level.

Can someone enlighten me?

--Ed

--
libvir-list mailing list
libvir-list redhat com
https://www.redhat.com/mailman/listinfo/libvir-list
Hi, Ed,
I am not a libvirt developer, maybe I only talk about it with you under my understand,
and I hope it is helpful to you.

At first, it will be better if I explain simply libvirt's goal and some basic concept: 1.The goal of libvirt: to provide a common generic and stable layer to securely manage domains on a node.
2. what is the node?
A node is a single physical machine, in other words, a node is a host and a domain is an instance of an
operating system(also known guest)

Node devices should be some devices on the host, such as PCI device, In my opinion, you may understand
its function from the use, a group virsh comand can help you, for example:
[root dhcp-66-70-173 ~]# virsh help | grep node
nodeinfo node information
nodedev-list enumerate devices on this host
nodedev-dumpxml node device details in XML
nodedev-dettach dettach node device its device driver
nodedev-reattach reattach node device its device driver
nodedev-reset reset node device
nodedev-create create a device defined by an XML file on the node
nodedev-destroy destroy a device on the node

1. display host information
[root dhcp-66-70-173 ~]# virsh nodeinfo
CPU model: x86_64
CPU(s): 2
CPU frequency: 2327 MHz
CPU socket(s): 1
Core(s) per socket: 2
Thread(s) per core: 1
NUMA cell(s): 1
Memory size: 2014320 kB

2. display devices on the host
[root dhcp-66-70-173 ~]# virsh nodedev-list --tree
computer
|
+-pci_8086_10bd
| |
| +-net_00_1e_4f_db_02_5c
|
+-pci_8086_244e
+-pci_8086_2914
......

3. display specify device xml description
[root dhcp-66-70-173 ~]# virsh nodedev-dumpxml pci_8086_10bd
<device>
<name>pci_8086_10bd</name>
<parent>computer</parent>
<capability type='pci'>
<domain>0</domain>
<bus>0</bus>
<slot>25</slot>
<function>0</function>
<product id='0x10bd'>82566DM-2 Gigabit Network Connection</product>
<vendor id='0x8086'>Intel Corporation</vendor>
</capability>
</device>

4. dettach host device its device driver
[root dhcp-66-70-173 ~]# virsh nodedev-dettach pci_8086_10bd
Device pci_8086_10bd dettached

in fact, the operation hide the device host driver and bind the device to pci-stub driver
[root dhcp-66-70-173 ~]# readlink /sys/bus/pci/devices/0000\:00\:19.0/driver
../../../bus/pci/drivers/pci-stub

5. in order to return the device a certain&clean status, we need to reset the device
[root dhcp-66-70-173 ~]# virsh nodedev-reset pci_8086_10bd
Device pci_8086_10bd reset

6. return the device from guest to host
[root dhcp-66-70-173 ~]# virsh nodedev-reattach pci_8086_10bd
Device pci_8086_10bd re-attached

From step 2 to step 6, this group operations is very useful, such as we pass through a host pci device to guest.

Best Regards,
Alex Jia


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