Changing boot device for a QEMU-KVM virtual machine

38,776

Solution 1

If libvirt doesn't reload VM settings on start/stop, virsh edit command may help. And please write entire XML file and libvirt version

Hmm... everything seems OK. Try adding

<boot dev='hd'/>
<boot dev='cdrom'/>
<bootmenu enable='yes'/>

to <os> section and look if cdrom appears in boot menu. Also try removing all <boot> records from <os> and adding

<boot order='1'/>

to <disk> section

Solution 2

If the VM is down, look for a stored saved image under /var/lib/libvirt/qemu/save - it will keep the old parameters alive, despite changes made via virsh edit. I deleted such image in a similar case where it kept looking for an non-existent network interface (and failing to boot due to this).

Share:
38,776
NukaRakuForgotEmail
Author by

NukaRakuForgotEmail

Learning and helping.

Updated on September 18, 2022

Comments

  • NukaRakuForgotEmail
    NukaRakuForgotEmail over 1 year

    I am trying to change the boot device for a VM. I go to the VM's XML file in /etc/libvirt/qemu and set <boot dev='cdrom' />. Still, it attempts to boot from the harddrive instead of the cdrom.

    I know I have an ISO image loaded on the CD-ROM virtual device.

    Am I not doing this correctly? I tried shutting down the VM completely and starting it back up to no avail. Perhaps I need to reload the settings somehow?

    Edit:

    By request of @Selivanov:

    $ libvirtd --version
    libvirtd (libvirt) 0.8.7
    

    And XML file:

    <domain type='kvm'>
      <name>nimmy.example.com</name>
      <uuid>(SNIP)</uuid>
      <memory>524288</memory>
      <currentMemory>524288</currentMemory>
      <vcpu>1</vcpu>
      <os>
        <type arch='x86_64' machine='rhel6.1.0'>hvm</type>
        <boot dev='cdrom'/>
      </os>
      <features>
        <acpi/>
        <apic/>
        <pae/>
      </features>
      <clock offset='utc'/>
      <on_poweroff>destroy</on_poweroff>
      <on_reboot>restart</on_reboot>
      <on_crash>restart</on_crash>
      <devices>
        <emulator>/usr/libexec/qemu-kvm</emulator>
        <disk type='file' device='disk'>
          <driver name='qemu' type='raw' cache='none'/>
          <source file='/var/lib/libvirt/images/nimmy.img'/>
          <target dev='hda' bus='ide'/>
          <address type='drive' controller='0' bus='0' unit='0'/>
        </disk>
        <disk type='file' device='cdrom'>
          <driver name='qemu' type='raw'/>
          <source file='/home/nimmy/CentOS-6.0-x86_64-netinstall.iso'/>
          <target dev='hdc' bus='ide'/>
          <readonly/>
          <address type='drive' controller='0' bus='1' unit='0'/>
        </disk>
        <controller type='ide' index='0'>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
        </controller>
        <interface type='network'>
          <mac address='(SNIP)'/>
          <source network='default'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
        </interface>
        <serial type='pty'>
          <target port='0'/>
        </serial>
        <console type='pty'>
          <target type='serial' port='0'/>
        </console>
        <input type='mouse' bus='ps2'/>
        <graphics type='vnc' port='-1' autoport='yes'/>
        <sound model='ac97'>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
        </sound>
        <video>
          <model type='cirrus' vram='9216' heads='1'/>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
        </video>
        <memballoon model='virtio'>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
        </memballoon>
      </devices>
    </domain>
    
  • NukaRakuForgotEmail
    NukaRakuForgotEmail over 12 years
    Apparently, I had to close virt-manager for the settings to reload. Is this the usual case? Is there a way to reload the settings? Also, I'm confused as to why the settings in virt-manager were not taking.
  • Selivanov Pavel
    Selivanov Pavel over 12 years
    You may reload libvirt-bin service, if it's init script in your distributive supports this, for example in ubuntu: sudo reload libvirt-bin. If you edited xml file with external editor, this is normal. If you used virsh edit or changed settings from virt-manager, this is bug.
  • Admin
    Admin almost 8 years
    If you edit the XML file you need to reload the VM to effect the updates. /etc/init.d/libvirt-bin reload
  • Philipp Ludwig
    Philipp Ludwig over 3 years
    virsh edit just yields error: command 'edit' requires <domain> option.
  • Tornado726
    Tornado726 over 2 years
    @PhilippLudwig, just add the name of your VM after the virsh edit command. The <domain> is the VM itself. For example, if your VM is named winserver2016, the command would be virsh edit winserver2016.