Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a KVM VM of FreeNAS 0.7.1 Shere (revision 5127) running on Ubuntu Server 10.04 and I'm unable to convince the VM to shutdown from the host

virsh shutdown freenas

I would expect this to send some ACPI? trigger to the VM and FreeNAS then do what it's told.

I'm not a FreeBSD fundi so I don't really know what packages or processes to poke to get this running. I have tried to convince powerd to run, but the VM cpus don't have the required freq entry

Sysctl HW

$ sysctl hw
hw.machine: amd64
hw.model: QEMU Virtual CPU version 0.12.3
hw.ncpu: 1
hw.byteorder: 1234
hw.physmem: 523116544
hw.usermem: 463806464
hw.pagesize: 4096
hw.floatingpoint: 1
hw.machine_arch: amd64
hw.realmem: 536850432
hw.aac.iosize_max: 65536
hw.amr.force_sg32: 0
hw.an.an_cache_iponly: 1
hw.an.an_cache_mcastonly: 0
hw.an.an_cache_mode: dbm
hw.an.an_dump: off
hw.ata.to: 15
hw.ata.wc: 1
hw.ata.atapi_dma: 1
hw.ata.ata_dma_check_80pin: 1
hw.ata.ata_dma: 1
hw.ath.txbuf: 200
hw.ath.rxbuf: 40
hw.ath.regdomain: 0
hw.ath.countrycode: 0
hw.ath.xchanmode: 1
hw.ath.outdoor: 1
hw.ath.calibrate: 30
hw.ath.hal.swba_backoff: 0
hw.ath.hal.sw_brt: 10
hw.ath.hal.dma_brt: 2
hw.bce.msi_enable: 1
hw.bce.tso_enable: 1
hw.bge.allow_asf: 0
hw.cardbus.cis_debug: 0
hw.cardbus.debug: 0
hw.cs.recv_delay: 570
hw.cs.ignore_checksum_failure: 0
hw.cs.debug: 0
hw.cxgb.snd_queue_len: 50
hw.cxgb.use_16k_clusters: 1
hw.cxgb.force_fw_update: 0
hw.cxgb.singleq: 0
hw.cxgb.ofld_disable: 0
hw.cxgb.msi_allowed: 2
hw.cxgb.txq_mr_size: 1024
hw.cxgb.sleep_ticks: 1
hw.cxgb.tx_coalesce: 0
hw.firewire.hold_count: 3
hw.firewire.try_bmr: 1
hw.firewire.fwmem.speed: 2
hw.firewire.fwmem.eui64_lo: 0
hw.firewire.fwmem.eui64_hi: 0
hw.firewire.phydma_enable: 1
hw.firewire.nocyclemaster: 0
hw.firewire.fwe.rx_queue_len: 128
hw.firewire.fwe.tx_speed: 2
hw.firewire.fwe.stream_ch: 1
hw.firewire.fwip.rx_queue_len: 128
hw.firewire.sbp.tags: 0
hw.firewire.sbp.use_doorbell: 0
hw.firewire.sbp.scan_delay: 500
hw.firewire.sbp.login_delay: 1000
hw.firewire.sbp.exclusive_login: 1
hw.firewire.sbp.max_speed: -1
hw.firewire.sbp.auto_login: 1
hw.mfi.max_cmds: 128
hw.mfi.event_class: 0
hw.mfi.event_locale: 65535
hw.pccard.cis_debug: 0
hw.pccard.debug: 0
hw.cbb.debug: 0
hw.cbb.start_32_io: 4096
hw.cbb.start_16_io: 256
hw.cbb.start_memory: 2281701376
hw.pcic.pd6722_vsense: 1
hw.pcic.intr_mask: 57016
hw.pci.honor_msi_blacklist: 1
hw.pci.enable_msix: 1
hw.pci.enable_msi: 1
hw.pci.do_power_resume: 1
hw.pci.do_power_nodriver: 0
hw.pci.enable_io_modes: 1
hw.pci.host_mem_start: 2147483648
hw.syscons.kbd_debug: 1
hw.syscons.kbd_reboot: 1
hw.syscons.bell: 1
hw.syscons.saver.keybonly: 1
hw.syscons.sc_no_suspend_vtswitch: 0
hw.usb.uplcom.interval: 100
hw.usb.uvscom.interval: 100
hw.usb.uvscom.opktsize: 8
hw.wi.debug: 0
hw.wi.txerate: 0
hw.xe.debug: 0
hw.intr_storm_threshold: 1000
hw.availpages: 127714
hw.bus.devctl_disable: 0
hw.ste.rxsyncs: 0
hw.busdma.total_bpages: 32
hw.busdma.zone0.total_bpages: 32
hw.busdma.zone0.free_bpages: 32
hw.busdma.zone0.reserved_bpages: 0
hw.busdma.zone0.active_bpages: 0
hw.busdma.zone0.total_bounced: 0
hw.busdma.zone0.total_deferred: 0
hw.busdma.zone0.lowaddr: 0xffffffff
hw.busdma.zone0.alignment: 2
hw.busdma.zone0.boundary: 65536
hw.clockrate: 2808
hw.instruction_sse: 1
hw.apic.enable_extint: 0
hw.kbd.keymap_restrict_change: 0
hw.acpi.supported_sleep_state: S3 S4 S5
hw.acpi.power_button_state: S5
hw.acpi.sleep_button_state: S3
hw.acpi.lid_switch_state: NONE
hw.acpi.standby_state: S1
hw.acpi.suspend_state: S3
hw.acpi.sleep_delay: 1
hw.acpi.s4bios: 0
hw.acpi.verbose: 0
hw.acpi.disable_on_reboot: 0
hw.acpi.handle_reboot: 0
hw.acpi.cpu.cx_lowest: C1

Processes

$ ps ax
  PID  TT  STAT      TIME COMMAND
    0  ??  DLs    0:00.00 [swapper]
    1  ??  ILs    0:00.00 /sbin/init --
    2  ??  DL     0:00.08 [g_event]
    3  ??  DL     0:00.29 [g_up]
    4  ??  DL     0:00.33 [g_down]
    5  ??  DL     0:00.00 [crypto]
    6  ??  DL     0:00.00 [crypto returns]
    7  ??  DL     0:00.00 [xpt_thrd]
    8  ??  DL     0:00.00 [kqueue taskq]
    9  ??  DL     0:00.00 [acpi_task_0]
   10  ??  RL    34:12.42 [idle: cpu0]
   11  ??  WL     0:01.13 [swi4: clock sio]
   12  ??  WL     0:00.00 [swi3: vm]
   13  ??  WL     0:00.00 [swi1: net]
   14  ??  DL     0:00.04 [yarrow]
   15  ??  WL     0:00.00 [swi6: task queue]
   16  ??  WL     0:00.00 [swi2: cambio]
   17  ??  DL     0:00.00 [acpi_task_1]
   18  ??  DL     0:00.00 [acpi_task_2]
   19  ??  WL     0:00.00 [swi5: +]
   20  ??  DL     0:00.01 [thread taskq]
   21  ??  WL     0:00.00 [swi6: Giant taskq]
   22  ??  WL     0:00.00 [irq9: acpi0]
   23  ??  WL     0:00.09 [irq14: ata0]
   24  ??  WL     0:00.11 [irq15: ata1]
   25  ??  WL     0:00.57 [irq11: ed0 uhci0]
   26  ??  DL     0:00.00 [usb0]
   27  ??  DL     0:00.00 [usbtask-hc]
   28  ??  DL     0:00.00 [usbtask-dr]
   29  ??  WL     0:00.01 [irq1: atkbd0]
   30  ??  WL     0:00.00 [swi0: sio]
   31  ??  DL     0:00.00 [sctp_iterator]
   32  ??  DL     0:00.00 [pagedaemon]
   33  ??  DL     0:00.00 [vmdaemon]
   34  ??  DL     0:00.00 [idlepoll]
   35  ??  DL     0:00.00 [pagezero]
   36  ??  DL     0:00.01 [bufdaemon]
   37  ??  DL     0:00.00 [vnlru]
   38  ??  DL     0:00.14 [syncer]
   39  ??  DL     0:00.01 [softdepflush]
 1221  ??  Is     0:00.00 /sbin/devd
 1289  ??  Is     0:00.01 /usr/sbin/syslogd -ss -f /var/etc/syslog.conf
 1608  ??  Is     0:00.00 /usr/sbin/cron -s
 1692  ??  Ss     0:00.03 /usr/local/sbin/mDNSResponderPosix -b -f /var/etc/mdn
 1730  ??  S      0:00.43 /usr/local/sbin/lighttpd -f /var/etc/lighttpd.conf -m
 1882  ??  DL     0:00.00 [system_taskq]
 1883  ??  DL     0:00.00 [arc_reclaim_thread]
 4139  ??  S      0:00.03 /usr/local/bin/php /usr/local/www/exec.php
 4144  ??  S      0:00.00 sh -c ps ax
 4145  ??  R      0:00.00 ps ax
 1816  v0  Is     0:00.01 login [pam] (login)
 1818  v0  I+     0:00.03 -tcsh (csh)
 1817  v1  Is+    0:00.00 /usr/libexec/getty Pc ttyv1
 1402 con- I      0:00.00 /usr/local/sbin/afpd -F /var/etc/afpd.conf
 1404 con- S      0:00.00 /usr/local/sbin/cnid_metad
 1682 con- I      0:02.78 /usr/local/sbin/mt-daapd -m -c /var/etc/mt-daapd.conf
 1789 con- S      0:00.18 /usr/local/bin/fuppesd --config-dir /var/etc --config

Libvert snippet

<domain type='kvm'>
  <name>freenas</name>
  <uuid>********-****-****-****-************</uuid>
  <memory>524288</memory>
  <currentMemory>524288</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-0.12'>hvm</type>
    <boot dev='hd'/>
  </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/bin/kvm</emulator>

Is this possible? Ideally I'd like to be able to stop the host without having to manually deal with shutting down the VM.

share|improve this question
add comment

2 Answers

The only way I've found to get this working is to pass the -no-kvm-irqchip parameter to kvm. The easiest way to do this in libvirt is to create a wrapper script (eg /usr/local/bin/kvmbsd)

#!/bin/sh
exec /usr/bin/kvm "$@" -no-kvm-irqchip

And change the emulator line in your libvirt configuration to point to the wrapper script.

/usr/local/bin/kvmbsd

This allows me to cleanly shutdown (but not reboot - this doesn't appear to be implemented in libvirt/kvm yet) my freebsd based vms.

share|improve this answer
add comment

Make sure the VM has ACPI enabled, that's what a clean shutdown does - send an ACPI call. There are other ways however, like scripting a shutdown command through ssh, using monitorCommand sendKey to send a keypress designed to initiate a shutdown, running a "destroy" command (essentially a plug pull) etc.

share|improve this answer
    
If you look at the libvirt snippet, you can see the <acpi/> feature... –  ptomli Sep 21 '10 at 9:34
    
does the OS have ACPI enabled though? –  dyasny Sep 21 '10 at 9:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.