From Fedora Project Wiki


This test case checks that NIC hotplug works correctly with virsh attach-device and virsh attach-interface.

How to test

  1. Start a guest with no NIC - i.e. use virsh edit to ensure there is no <interface>
  2. Create an XML file which looks something like:
    <interface type='network'>
    <mac address='52:54:00:ab:cd:ef'/>
    <source network='default'/>
    <model type='virtio'/>
  3. Attach the interface to the guest:
    $> virsh attach-device <guest-name> <interface-XML>
    Device attached successfully
  4. Check that the guest saw the device e.g. (in the guest):
    $> dmesg
    virtio-pci: 0000:00:06.0: enabling device (0000 -> 0003)
    $> lspci
    00:06.0 Ethernet controller: Qumranet, Inc. Virtio network device
    $> ifconfig eth0
    $> ping
  5. Detach the interface:
    $> virsh detach-device <guest-name> <interface-XML>
    Device detached successfully
  6. Check the guest can no longer see the interface using the same commands as above
  7. Repeat with different values for model - e.g. e1000 and rtl8139
  8. Attach an interface using virsh attach-interface
    $> virsh attach-interface <guest-name> network default
    Interface attached successfully
  9. And detach it again:
    $> virsh detach-interface <guest-name> network
    Interface detached successfully

Expected Results

  1. All operations should complete successfully
  2. The attached interface should appear in the guest
  3. The guest should have usable network connectivity using the attached interface