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

Re: [libvirt] [PATCH 00/34] Add device addressing and disk controller support



On Fri, Jan 08, 2010 at 05:22:56PM +0000, Daniel P. Berrange wrote:
> This series is a merge of two previous series I posted
> 
>   http://www.redhat.com/archives/libvir-list/2009-December/msg00232.html
>   http://www.redhat.com/archives/libvir-list/2009-December/msg00392.html
> 
> It accomplishes quite a lot of things, having major impact on the QEMU
> driver, hopefully all in a postive way :-)
> 
> In particular it does
> 
>  * Add standard XML syntax for addressing of PCI devices, and disk drives
>  * Add support for disk controllers as a managed device in XML
>  * Add support for disk controller hotplug/unplug
>  * Convert everything over to use QEMU's -device flag where available
>  * Add PCI addressing when using -device
>  * Introduce a way to give every device a unique 'alias' name in
>    the XML format
> 
> I can't promise it works perfectly, but i've done quite alot of positive
> testing with it now & believe all the back comptability stuff is working
> right.

Since this is a long series, it might be helpful to see the results in
the XML and command line

Starting with this initial XML config which the application defines

<domain type='kvm' id='2'>
  <name>everything</name>
  <uuid>c7a1edbd-edaf-9455-926a-d65c36db1809</uuid>
  <memory>219200</memory>
  <currentMemory>219136</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='i686' machine='pc-0.11'>hvm</type>
    <kernel>/home/berrange/vmlinuz-PAE</kernel>
    <initrd>/home/berrange/initrd-PAE.img</initrd>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/home/berrange/usr/qemu-0.12/bin/qemu</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/berrange/VirtualMachines/plain.qcow'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <disk type='file' device='cdrom'>
      <source file='/home/berrange/gpxe.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
    </disk>
    <disk type='file' device='disk'>
      <source file='/home/berrange/output.img'/>
      <target dev='sdb' bus='usb'/>
    </disk>
    <disk type='file' device='disk'>
      <source file='/home/berrange/output.img'/>
      <target dev='sda' bus='scsi'/>
    </disk>
    <disk type='file' device='disk'>
      <source file='/home/berrange/output.img'/>
      <target dev='sdz' bus='scsi'/>
    </disk>
    <disk type='file' device='disk'>
      <source file='/home/berrange/output.img'/>
      <target dev='sdaf' bus='scsi'/>
    </disk>
    <interface type='user'>
      <mac address='52:54:00:5b:ef:21'/>
      <model type='ne2k_pci'/>
    </interface>
    <interface type='mcast'>
      <mac address='52:54:00:1c:dc:98'/>
      <source address='230.0.0.1' port='5558'/>
      <model type='virtio'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:f7:c5:0e'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='e1000'/>
    </interface>
    <interface type='user'>
      <mac address='52:54:00:56:6c:55'/>
      <model type='pcnet'/>
    </interface>
    <interface type='user'>
      <mac address='52:54:00:ca:0d:58'/>
      <model type='rtl8139'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/10'/>
      <target port='0'/>
    </serial>
    <parallel type='pty'>
      <source path='/dev/pts/17'/>
      <target port='0'/>
    </parallel>
    <console type='pty' tty='/dev/pts/10'>
      <source path='/dev/pts/10'/>
      <target port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes'/>
    <sound model='ac97'/>
    <sound model='es1370'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x15' slot='0x00' function='0x0'/>
      </source>
    </hostdev>
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <address bus='4' device='2'/>
      </source>
    </hostdev>
    <watchdog model='i6300esb' action='reset'/>
  </devices>
</domain>   


With the latest QEMU we now generate command line that looks like this

LC_ALL=C
PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
HOME=/root
USER=root
LOGNAME=root
QEMU_AUDIO_DRV=none

/home/berrange/usr/qemu-0.12/bin/qemu
  -S
  -M pc-0.11
  -enable-kvm
  -m 214
  -smp 1

  -name everything
  -uuid c7a1edbd-edaf-9455-926a-d65c36db1809

  -nodefaults

  -chardev socket,id=monitor,path=/var/lib/libvirt/qemu/everything.monitor,server,nowait
  -mon chardev=monitor,mode=readline

  -boot c
  -kernel /home/berrange/vmlinuz-PAE
  -initrd /home/berrange/initrd-PAE.img

  -device lsi,id=scsi0,addr=13
  -device lsi,id=scsi1,addr=14
  -device lsi,id=scsi2,addr=15
  -device lsi,id=scsi3,addr=16
  -device lsi,id=scsi4,addr=17

  -drive file=/home/berrange/VirtualMachines/plain.qcow,if=none,id=drive-virtio-disk0,format=qcow2
  -device virtio-blk-pci,addr=4,drive=drive-virtio-disk0,id=virtio-disk0

  -drive file=/home/berrange/gpxe.iso,if=none,media=cdrom,id=drive-ide0-1-0
  -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0

  -drive file=/home/berrange/output.img,if=none,id=drive-usb-disk1
  -device usb-storage,drive=drive-usb-disk1,id=usb-disk1

  -drive file=/home/berrange/output.img,if=none,id=drive-scsi0-0-0
  -device scsi-disk,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0

  -drive file=/home/berrange/output.img,if=none,id=drive-scsi3-0-4
  -device scsi-disk,bus=scsi3.0,scsi-id=4,drive=drive-scsi3-0-4,id=scsi3-0-4

  -drive file=/home/berrange/output.img,if=none,id=drive-scsi4-0-3
  -device scsi-disk,bus=scsi4.0,scsi-id=3,drive=drive-scsi4-0-3,id=scsi4-0-3

  -netdev user,id=netdev0
  -device ne2k_pci,netdev=netdev0,id=ne2k_pci-nic0,mac=52:54:00:5b:ef:21,addr=5

  -netdev socket,mcast=230.0.0.1:5558,id=netdev1
  -device virtio-net-pci,netdev=netdev1,id=virtio-nic1,mac=52:54:00:1c:dc:98,addr=6

  -netdev tap,fd=21,id=netdev2
  -device e1000,netdev=netdev2,id=e1000-nic2,mac=52:54:00:f7:c5:0e,addr=7

  -netdev user,id=netdev3
  -device pcnet,netdev=netdev3,id=pcnet-nic3,mac=52:54:00:56:6c:55,addr=8

  -netdev user,id=netdev4
  -device rtl8139,netdev=netdev4,id=rtl8139-nic4,mac=52:54:00:ca:0d:58,addr=9

  -chardev pty,id=serial0
  -device isa-serial,chardev=serial0

  -chardev pty,id=parallel0
  -device isa-parallel,chardev=parallel0

  -usb
  -device usb-tablet,id=input0

  -vnc 127.0.0.1:0
  -vga cirrus

  -device AC97,id=sound0,addr=10

  -device ES1370,id=sound1,addr=11

  -device i6300esb,id=watchdog0,addr=18
  -watchdog-action reset

  -device pci-assign,host=15:00.0,id=hostpci0,addr=12

  -device usb-host,hostbus=004,hostaddr=002,id=hostusb1 



If you query the XML dump while the VM is running, you'll see the extra
address information, alias names, and disk controller elements present.
eg like this


<domain type='kvm' id='2'>
  <name>everything</name>
  <uuid>c7a1edbd-edaf-9455-926a-d65c36db1809</uuid>
  <memory>219200</memory>
  <currentMemory>219136</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='i686' machine='pc-0.11'>hvm</type>
    <kernel>/home/berrange/vmlinuz-PAE</kernel>
    <initrd>/home/berrange/initrd-PAE.img</initrd>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/home/berrange/usr/qemu-0.12/bin/qemu</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/home/berrange/VirtualMachines/plain.qcow'/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <source file='/home/berrange/gpxe.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <alias name='ide0-1-0'/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <source file='/home/berrange/output.img'/>
      <target dev='sdb' bus='usb'/>
      <alias name='usb-disk1'/>
    </disk>
    <disk type='file' device='disk'>
      <source file='/home/berrange/output.img'/>
      <target dev='sda' bus='scsi'/>
      <alias name='scsi0-0-0'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <source file='/home/berrange/output.img'/>
      <target dev='sdz' bus='scsi'/>
      <alias name='scsi3-0-4'/>
      <address type='drive' controller='3' bus='0' unit='4'/>
    </disk>
    <disk type='file' device='disk'>
      <source file='/home/berrange/output.img'/>
      <target dev='sdaf' bus='scsi'/>
      <alias name='scsi4-0-3'/>
      <address type='drive' controller='4' bus='0' unit='3'/>
    </disk>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='scsi' index='0'>
      <alias name='scsi1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
    </controller>
    <controller type='scsi' index='1'>
      <alias name='scsi2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
    </controller>
    <controller type='scsi' index='2'>
      <alias name='scsi3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
    </controller>
    <controller type='scsi' index='3'>
      <alias name='scsi4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0f' function='0x0'/>
    </controller>
    <controller type='scsi' index='4'>
      <alias name='scsi5'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
    </controller>
    <interface type='user'>
      <mac address='52:54:00:5b:ef:21'/>
      <model type='ne2k_pci'/>
      <alias name='ne2k_pci-nic0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </interface>
    <interface type='mcast'>
      <mac address='52:54:00:1c:dc:98'/>
      <source address='230.0.0.1' port='5558'/>
      <model type='virtio'/>
      <alias name='virtio-nic1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:f7:c5:0e'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='e1000'/>
      <alias name='e1000-nic2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </interface>
    <interface type='user'>
      <mac address='52:54:00:56:6c:55'/>
      <model type='pcnet'/>
      <alias name='pcnet-nic3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>
    <interface type='user'>
      <mac address='52:54:00:ca:0d:58'/>
      <model type='rtl8139'/>
      <alias name='rtl8139-nic4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/10'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <parallel type='pty'>
      <source path='/dev/pts/17'/>
      <target port='0'/>
      <alias name='parallel0'/>
    </parallel>
    <console type='pty' tty='/dev/pts/10'>
      <source path='/dev/pts/10'/>
      <target port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes'/>
    <sound model='ac97'>
      <alias name='sound0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </sound>
    <sound model='es1370'>
      <alias name='sound1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </sound>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x15' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
      <alias name='hostpci0'/>
    </hostdev>
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <address bus='4' device='2'/>
      </source>
      <alias name='hostusb1'/>
    </hostdev>
    <watchdog model='i6300esb' action='reset'>
      <alias name='watchdog0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
    </watchdog>
  </devices>
  <seclabel type='dynamic' model='selinux'>
    <label>system_u:system_r:svirt_t:s0:c133,c417</label>
    <imagelabel>system_u:object_r:svirt_image_t:s0:c133,c417</imagelabel>
  </seclabel>
</domain>   


Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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