Commit Graph

323 Commits

Author SHA1 Message Date
Mark McLoughlin
0165410712 Retain disk PCI address across libvirtd restarts
When we hot-plug a disk device into a qemu guest, we need to retain its
PCI address so that it can be removed again later. Currently, we do
retain the slot number, but not across libvirtd restarts.

Add <state devaddr="xxxx:xx:xx"/> to the disk device XML config when the
VIR_DOMAIN_XML_INTERNAL_STATUS flag is used. We still don't parse the
domain and bus number, but the format allows us to do that in future.

* src/domain_conf.h: replace slotnum with pci_addr struct, add helper
  for testing whether the address is valid

* src/domain_conf.c: handle formatting and parsing the address

* src/qemu_driver.c: store the parsed slot number as a full PCI address,
  and use this address with the pci_del monitor command

* src/vbox/vbox_tmpl.c: we're debug printing slotnum here even though
  it can never be set, just delete it
2009-07-22 11:34:05 +01:00
Jun Koi
b2fd033cd5 Fix an uninitialized variable in Unix socket open
* src/qemu_driver.c: qemudOpenMonitorUnix() had an uninitialized loop
  counter
2009-07-21 11:57:54 +02:00
Cole Robinson
3b5417687d qemu: Try multiple times to open unix monitor socket
Unlike the pty monitor (which we know exists since we scrape its path from
stdout), we have no way of knowing that the unix monitor socket should exist/
be initialized. As a result, some of my KVM guests randomly fail to start on
F10 host.

Try to open the unix socket in a 3 second timeout loop. Ignore EACCES (path
does not exist if a first time run) and ECONNREFUSED (leftover socket from
a previous run hasn't been removed yet). Fixes things for me.
2009-07-16 12:52:53 -04:00
Daniel P. Berrange
0714b2ba4c Run QEMU guests as an unprivileged user
* configure.in: Add --with-qemu-user and --with-qemu-group args
* libvirt.spec.in: use 'qemu' for user/group for Fedora >= 12
* qemud/libvirtd_qemu.arg, qemud/test_libvirtd_qemu.aug,
  src/qemu.conf: Add 'user' and 'group' args for configuration
* src/Makefile.am: Create %localstatedir/cache/libvirt/qemu
* src/qemu_conf.c, src/qemu_conf.h: Load user/group from config
* src/qemu_driver.c: Change user ID/group ID when launching QEMU
  guests. Change user/group ownership on disks/usb/pci devs.
  Put memory dumps in %localstatedir/cache/libvirt/qemu
* src/util.c, src/util.h: Add convenient APIs for converting
  username/groupname to user ID / group ID
2009-07-16 17:06:55 +01:00
Paolo Bonzini
e1abc44814 Implement qemu dump capabilities
* src/qemu_driver.c (qemudDomainCoreDump): New
  (qemuDriver): Add core dump function. The behaviour is similar
  as the current Xen dump
2009-07-16 16:50:23 +02:00
Daniel P. Berrange
1795bfe4a1 Fix SELinux denial during hotplug
* src/qemu_driver.c: Relabel disk images *before* running QEMU
hotplug monitor commands
2009-07-16 11:32:09 +01:00
Daniel P. Berrange
326ecb7814 Fix PCI device hotplug/unplug with newer QEMU
* src/qemu_driver.c: Try new monitor syntax for hotplug first. If
  that fails fallback to old KVM specific syntax
2009-07-16 11:32:09 +01:00
Daniel P. Berrange
2d1f2e706c Fix problem with QEMU monitor welcome prompt confusing libvirt
after a libvirtd daemon restart with active guests

* src/qemu_driver: Read and dicard pending monitor data
  before issuing new monitor commands.
2009-07-16 11:32:03 +01:00
Cole Robinson
fe7cb869a8 qemu: Check driver is initialized up front, to avoid segfault.
If the qemu_driver was not initialized (possibly due to an error on driver
startup), we can segfault if attempting to connect to the URI.
2009-07-10 19:29:31 -04:00
Mark McLoughlin
62455ed872 Switch to using a unix socket for the qemu monitor
We keep support for the pty based monitor so that we can re-connect
to VMs started by older versions of libvirtd.

* src/domain_conf.c: handle formatting and parsing unix monitors

* src/qemu_driver.c: add qemudOpenMonitorUnix(), remove the monitor
  pty path searching from qemudFindCharDevicePTYs(), switch
  qemudStartVMDaemon() and qemuDomainXMLToNative() to using a unix
  monitor

* tests/qemuxml2argvtest.c: switch to using a unix monitor

* tests/qemuxml2argvdata/qemuxml2argv-*.args: update test data
2009-07-09 20:04:09 +01:00
Mark McLoughlin
05d377bdd2 Add the monitor type to the domain state XML
There are no functional changes in this patch apart from adding the
monitor type to the state XML.

The patch mostly consists of switching to use virDomainChrDef every
where to describe the monitor.

* src/domain_conf.h: replace monitorpath with monitor_chr

* src/domain_conf.c: handle parsing the monitor type and initializing
  monitor chr

* src/qemu_conf.[ch]: make qemudBuildCommandLine take a
  virDomainChrDefPtr and use that to build the -monitor parameter

* src/qemu_driver.c: split pty specific and common code from
  qemudOpenMonitor, have qemudStartVMDaemon() initialize monitor_chr

* tests/qemuxml2argvtest.c: update for qemudBuildCommandLine() change
2009-07-09 20:04:07 +01:00
Mark McLoughlin
1f4ec305f0 Minor qemu monitor coding style fixes
* src/qemu_driver.c: use a consistent coding style for function
  definitions
2009-07-09 19:31:01 +01:00
Mark McLoughlin
8a52daa2d4 Don't leak vm->monitorpath on re-connect
* src/qemu_driver.c: vm->monitorpath is already initialized in the case
  of re-connect, so move the initialization for the normal startup case
  out of the common code
2009-07-09 19:31:01 +01:00
Daniel P. Berrange
96619805cb Use libcap-ng to clear capabilities for many child processes 2009-06-29 17:00:52 +00:00
Daniel P. Berrange
39c7e7a6b7 Fix crash in QEMU driver with bad capabilities data 2009-06-29 10:41:56 +00:00
Daniel Veillard
d45242c616 Fix a couple of state problems
* src/qemu_driver.c: fix a domain state problem after
  migration, patch  by Federico Simoncelli, fixes #507537
* src/domain_conf.c:  fix a transcient domain state problem after
  destroy, patch  by Federico Simoncelli, fixes #507304
* AUTHORS: add Federico Simoncelli and Javier Fontan
daniel
2009-06-25 13:55:58 +00:00
Daniel P. Berrange
73f34b31f5 Fix broken dominfo command when no security driver is implemented 2009-06-25 09:37:22 +00:00
Cole Robinson
387935345c Fix memory reporting for inactive domains in the qemu driver.
Currently, 'info' will always report that mem = max mem. Make sure we
actually return the correct mem value.
2009-06-22 16:35:03 +00:00
Cole Robinson
53603043c7 Set default emulator in domain_conf.*, rather than the driver.
Rather than numerous instances of:

emulator = vm->def->emulator;
if (!emulator)
    emulator = virDomainDefDefaultEmulator(conn, vm->def, driver->caps);
if (!emulator)
    return -1;

Set this value at XML parse time in the domain config, so we can depend on
it for all future emulator accesses. There were unchecked accesses in the
qemu driver that were tripping up on this if no emulator was specified in
the XML, see:

http://www.redhat.com/archives/libvir-list/2008-October/msg00602.html
2009-06-16 15:42:46 +00:00
Daniel P. Berrange
0420a03240 Remove use of getuid()==0 for privilege checks 2009-06-12 13:20:13 +00:00
Daniel P. Berrange
d2c9fe850b Improve error reporting for virConnectOpen URIs 2009-06-12 12:06:15 +00:00
Daniel P. Berrange
56a46886ad Fix re-detection of transient VMs after libvirtd restart 2009-06-12 11:38:50 +00:00
Daniel P. Berrange
b0b968efd5 Generic shared impls of all NUMA apis 2009-06-03 13:28:02 +00:00
Daniel Veillard
81d0ffbc3b NPIV implementation for node device create and destroy
* src/Makefile.am src/node_device.[ch] src/node_device_conf.[ch]
  src/node_device_hal.[ch] src/node_device_hal_linux.c
  src/qemu_driver.c src/remote_internal.c src/storage_backend.c
  src/virsh.c src/xen_unified.c tests/nodedevxml2xmltest.c
  po/POTFILES.in: implementation for node device create and destroy
  in NPIV support, patch by David Allan
Daniel
2009-06-02 15:12:53 +00:00
Cole Robinson
34497fdb37 qemu_driver: Fix another domain startup error reporting race.
Parse the command line output a bit earlier so we have a better chance
of reporting the full error output on failure.

I hit this when QEMU would try to boot an invalid kernel (virtinst bug).
2009-05-29 14:12:50 +00:00
Cole Robinson
4ff19ced3a qemuDomainLookupByUUID: print correct UUID string on failed lookup.
Currently we print the raw UUID which isn't very useful in ascii format.
2009-05-29 14:01:55 +00:00
Daniel P. Berrange
c31300e69f Fix misc bugs in ARGV -> XML convertor 2009-05-28 13:21:19 +00:00
Daniel P. Berrange
3d4a0ccbc6 QEMU domain XML conversion from QEMU argv 2009-05-21 14:16:55 +00:00
Daniel P. Berrange
d8dbd61107 Basic domain XML conversions for Xen/QEMU drivers 2009-05-21 14:14:01 +00:00
Daniel P. Berrange
4d5383fd36 public API for domain XML conversions 2009-05-21 13:46:35 +00:00
Daniel P. Berrange
de658ab4e4 Fix misc locking bugs identified by lock checker 2009-05-19 11:06:25 +00:00
Daniel Veillard
cd223d93da generic support for RDP and desktop graphic extensions
* docs/schemas/domain.rng src/domain_conf.[ch] src/qemu_driver.c:
  extend the generic code for the RDP and desktop extensions of
  the graphic tag needed for vbox, patch by Pritesh Kothari
Daniel
2009-05-15 09:43:51 +00:00
Daniel P. Berrange
426f9772b8 Fix QEMU ARGV detection with kvm >= 85 2009-05-11 15:14:24 +00:00
Cole Robinson
0c8a9d2d51 Check that QEMU is still alive while reading startup output.
By checking the pid every retry period, we can quickly determine if
the process crashed at startup, rather than make the user wait for
the entire timeout (3 seconds).
2009-05-11 13:52:31 +00:00
Cole Robinson
a331653dad Add pidfile argument to __virExec
virExec will write out the pid of the daemonized process only. Use this
in the QEMU driver, rather than QEMU's pidfile, so we can catch errors we
might miss if the emulator bails early.
2009-05-11 13:50:38 +00:00
Cole Robinson
27d72bd517 Report qemu log data if we fail to daemonize the process.
This ensures the user will actually see 'hook' function error output.
2009-05-11 13:37:19 +00:00
Cole Robinson
79d9d2432f Add helper function virExecDaemonize
Wraps __virExec with the VIR_EXEC_DAEMON flag. Waits on the intermediate
process to ensure we don't end up with any zombies, and differentiates between
original process errors and intermediate process errors.
2009-05-11 13:34:37 +00:00
Daniel P. Berrange
54ebbde1e1 Improve name & UUID uniqueness checking in QEMU driver 2009-05-08 10:11:14 +00:00
Daniel P. Berrange
7022759b7e Add new VIR_ERR_OPERATION_INVALID error code & use it in Xen & QEMU drivers 2009-05-08 09:58:46 +00:00
Daniel Veillard
7ee54d8356 Changes needed for multiple graphics adapters
* src/domain_conf.c src/domain_conf.h: parse and save multiple
  graphics elements instead of one, patch by Pritesh Kothari
* src/qemu_conf.c src/qemu_driver.c: adapt the qemu/kvm driver for
  the new structures, patch by Pritesh Kothari
* src/xend_internal.c src/xm_internal.c: same thing for Xen drivers
Daniel
2009-05-07 07:27:49 +00:00
Mark McLoughlin
1d6c713b18 Fix qemu driver's interpretation of <hostdev managed='yes'/>
This change:

  Tue Mar  3 08:55:13 GMT 2009 Daniel P. Berrange <berrange@redhat.com>

       Don't try to detach & reset PCI devices while running test
       suite for XML-> ARGV conversion.
       * src/qemu_driver.c: Add qemuPrepareHostDevices() helper to
       detach and reset PCI devices.
       * src/qemu_conf.c: Don't detach & reset PCI devices while
       building the command line argv

accidentally did this:

-            if (hostdev->managed) {
+        if (!hostdev->managed) {

Which results in managed='yes' not causing the device to be
detached when the guest is starting.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-05-06 15:56:20 +00:00
Cole Robinson
4f10759024 Refresh QEMU driver capabilities for each getCapabilities call.
Also fix up a couple issues where caps are accessed without locking
the driver structure.
2009-05-06 14:20:34 +00:00
Cole Robinson
840955ff7c Don't throw away StartVM errors when migrating/restoring in qemu driver. 2009-05-05 14:26:02 +00:00
Daniel P. Berrange
9c19a898f9 Remove stale QEMU pidfiles 2009-04-21 19:14:50 +00:00
Daniel P. Berrange
cfa30de3b8 Improve error reporting for lookup failures on inactive domains 2009-04-19 15:30:50 +00:00
Daniel P. Berrange
9a15c48d2d Switch to using virDomainDefPtr for building command line in QEMU driver 2009-04-19 14:50:01 +00:00
Guido Günther
5caa1e0eb0 Don't log monitor output to domain log file.
It's logged via the logging system already. Prefix monitor debug output with vm
name.
2009-04-16 15:56:27 +00:00
Daniel P. Berrange
9ec1a56923 Fix crash in svirt verification, and incorrect cleanup in VM failure paths 2009-04-03 14:10:17 +00:00
Daniel P. Berrange
92ff72b52c Misc NUMA related fixes 2009-04-03 12:45:05 +00:00
Daniel P. Berrange
11b0ed46c5 Improve security label error reporting & verification (Dan Walsh) 2009-04-03 10:55:51 +00:00
Daniel P. Berrange
461afc2200 Fix URI check in QEMU migration 2009-04-01 09:54:20 +00:00
Chris Lalancette
4d3d0039e5 Convert all drivers to use old-style struct initializers; this makes a handy
built-in TODO list for each driver.  Also rip out the internal getURI method;
it is never used by any of the drivers, and was buggy to boot.
2009-03-31 15:47:16 +00:00
Daniel P. Berrange
3b97f7db53 DOn't try to query memory balloon if guest isn't active 2009-03-27 14:57:51 +00:00
Daniel P. Berrange
cb7593bd19 Support memory ballooning in QEMU 2009-03-27 11:44:29 +00:00
Daniel P. Berrange
c86afc85ee Fix labelling of shared/readonly devices (Dan Walsh) 2009-03-17 11:35:40 +00:00
Cole Robinson
2068f2f5a3 Initialize security driver after config parsing 2009-03-16 17:16:04 +00:00
Daniel P. Berrange
b44af714d3 Support SASL auth for VNC server. 2009-03-16 13:54:26 +00:00
Daniel P. Berrange
8fa62166c4 Avoid deadlock setting vcpus in QEMU driver 2009-03-16 11:44:46 +00:00
Daniel P. Berrange
aad6873175 Don't try to close NULL virConnectPtr object 2009-03-16 10:30:04 +00:00
Daniel P. Berrange
61796bdb4b Explicitly track static declared vs dynamically generated security labels 2009-03-03 16:53:13 +00:00
Daniel P. Berrange
e4818895c1 Misc sVirt bug fixes 2009-03-03 15:18:24 +00:00
Daniel P. Berrange
d0aa10fdd6 QEMU security driver usage for sVirt support (James Morris, Dan Walsh, Daniel Berrange) 2009-03-03 12:03:44 +00:00
Daniel P. Berrange
b756b005ec Replace use of qemudLog with logging.h APIs/macros 2009-03-03 11:40:08 +00:00
Daniel P. Berrange
8d13558ae6 Internal driver API for sVirt support (James Morris & Dan Walsh) 2009-03-03 09:14:28 +00:00
Daniel P. Berrange
8f1912c58d Don't try to detach & reset PCI devices while running test suite for XML-> ARGV conversion. 2009-03-03 08:59:45 +00:00
Cole Robinson
4837725f37 Better error reporting from qemu AttachDevice 2009-03-02 17:39:43 +00:00
Cole Robinson
adecc8fc9e Remove redundant monitor watch variable (s/monitor_watch/monitorWatch/) 2009-03-02 17:33:39 +00:00
Daniel Veillard
34d23b0b01 * src/qemu_driver.c: add qemu dettach/reattach/reset implementation
patch by Mark McLoughlin.
Daniel
2009-03-02 16:32:52 +00:00
Daniel Veillard
737af2ea04 Adds the APIs for virNodeDeviceDettach , ReAttach and Reset
* include/libvirt/libvirt.h include/libvirt/libvirt.h.in
  src/driver.h src/libvirt.c src/libvirt_public.syms
  src/lxc_driver.c src/openvz_driver.c src/qemu_driver.c
  src/test.c src/uml_driver.c: add the public APIs for
  virNodeDeviceDettach virNodeDeviceReAttach and virNodeDeviceReset
  and extends the driver structure accordingly.
Daniel
2009-03-02 16:25:13 +00:00
Chris Lalancette
014bb5cf7e If there is a failure during Qemu offline migrate, make sure to resume the
guest.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-02-27 16:18:50 +00:00
Guido Günther
4cbe86fcb8 (s)size_t type cleanup 2009-02-19 08:18:31 +00:00
Cole Robinson
7e8ad2036a Remove the _actually_ incorrect ATTRIBUTE_UNUSED (Patch by Maximilian Wilhelm) 2009-02-18 01:37:47 +00:00
Cole Robinson
cf47347312 Remove incorrect ATTRIBUTE_UNUSED usage. 2009-02-17 14:38:22 +00:00
Guido Günther
6efe591e66 usleep to wait for domain logfile to fill up 2009-02-13 11:35:16 +00:00
Guido Günther
e9c920ba67 fix return status when domain didn't show up 2009-02-11 20:33:11 +00:00
Guido Günther
0437e75291 Don't ignore errors to save domain status 2009-02-07 21:36:06 +00:00
Jim Meyering
dcfa920aff use virReportOOMError rather than more verbose equivalent
* src/qemu_driver.c (qemudDomainSave, qemudDomainRestore)
(qemudDomainAttachPciDiskDevice)
(qemudDomainAttachUsbMassstorageDevice):
2009-02-05 16:27:40 +00:00
Jim Meyering
e60430be53 qemu_driver.c: s/strerror/virStrerror.../
Perform most changs automatically, with this:
perl -pi -e 's/\bstrerror *\((.+?)\)/virStrerror($1, ebuf, sizeof ebuf)/'
Then, declare ebuf, as needed
2009-02-05 16:27:28 +00:00
Jim Meyering
b0d49913d5 remove duplicate *SetCloseExec and *SetNonBlock functions
* src/qemu_driver.c: Use virSetCloseExec and virSetNonBlock,
rather than qemuSet* functions.  Suggested by Daniel P. Berrange.
* src/util.c (virSetCloseExec): Publicize.
* src/util.h (virSetCloseExec): Declare
* src/libvirt_private.syms: Add virSetCloseExec.
2009-02-05 16:27:17 +00:00
Jim Meyering
caea9c00e3 qemu_driver.c: use virReportSystemError in place of some qemudLog uses
...thus eliminating many uses of strerror.
(kvmGetMaxVCPUs): Rather than merely warning, diagnose an error
and return -1 upon failure to open KVM_DEVICE.  Suggested by
Daniel P. Berrange.
2009-02-05 16:11:25 +00:00
Jim Meyering
6778ad0f07 avoid a format-related warning
* src/qemu_driver.c (qemudStartVMDaemon): Use "%s".
2009-02-03 13:09:18 +00:00
Daniel P. Berrange
896761e5c7 Fix numerous bugs in QEMU domain startup 2009-01-30 17:07:29 +00:00
Daniel P. Berrange
3801794908 Support VNC password setting in QEMU driver 2009-01-29 17:50:00 +00:00
Daniel P. Berrange
4f4bfbc79e Fix save/restore migrate syntax for new KVM releases 2009-01-29 17:27:54 +00:00
Jim Meyering
bc18a91f91 error-reporting calls using VIR_ERR_NO_MEMORY: use virReportOOMError instead
* src/uml_conf.c (VIR_FROM_THIS): Define to VIR_FROM_UML.
* src/xs_internal.c (VIR_FROM_THIS): Define to VIR_FROM_XEN.
* src/xml.c (VIR_FROM_THIS): Define to VIR_FROM_XML.
* src/stats_linux.c (VIR_FROM_THIS): Define to VIR_FROM_STATS_LINUX.
* src/datatypes.c (VIR_FROM_THIS): Define to VIR_FROM_NONE.
* src/lxc_conf.c (VIR_FROM_THIS): Define to VIR_FROM_LXC.
* src/libvirt.c (VIR_FROM_THIS): Define to VIR_FROM_NONE.
* src/node_device_conf.c (VIR_FROM_THIS): Define to VIR_FROM_NODEDEV.
* src/openvz_conf.c (VIR_FROM_THIS): Define to VIR_FROM_OPENVZ.
* src/openvz_driver.c (VIR_FROM_THIS): Define to VIR_FROM_OPENVZ.
* src/conf.c (VIR_FROM_THIS): Define to VIR_FROM_CONF.
Note: this loses config_filename:config_lineno diagnostics,
but that's ok.
* src/node_device.c (VIR_FROM_THIS): Define to VIR_FROM_NODEDEV.
* src/sexpr.c (VIR_FROM_THIS): Define to VIR_FROM_SEXPR.
* po/POTFILES.in: remove src/sexpr.c and src/lxc_conf.c
2009-01-29 12:10:32 +00:00
Daniel P. Berrange
1b745219c7 Remove use of non-reentrant POSIX apis 2009-01-22 19:41:48 +00:00
Daniel P. Berrange
437ac354fc Make error reporting threadsafe by avoiding strerror 2009-01-20 17:13:33 +00:00
Daniel Veillard
25415eb104 * src/qemu_driver.c: remove a warning when printing a file offset
daniel
2009-01-20 16:39:35 +00:00
Daniel Veillard
6d004d3f8a * src/domain_conf.h src/qemu_driver.c: use monitor fd for QEmu/KVM
domain shutdown and read saved vm status on libvirtd startup,
  last 2 patches from Guido Günther finishing up the surviving the
  libvirt daemon restart
daniel
2009-01-20 15:52:11 +00:00
Guido Günther
8dfbfe3145 daemonize qemu processes 2009-01-19 21:55:54 +00:00
Daniel P. Berrange
4dac0a1105 Generic internal threads API 2009-01-15 19:56:05 +00:00
Guido Günther
8af87ea251 don't emulate snprintf 2009-01-11 11:21:29 +00:00
Guido Günther
4275be68fb split out opening of the qemu logfile 2009-01-11 11:18:31 +00:00
Guido Günther
46971d5ed7 pass flags argument to all virDomain*DefParse* functions 2009-01-08 13:54:20 +00:00
Daniel Veillard
fbba4423e9 * src/libvirt_private.syms src/qemu_driver.c src/test.c
src/uml_driver.c src/util.c src/util.h src/xen_unified.c:
  unify hostname lookup using virGetHostname convenience function,
  patch by David Lutterkort
daniel
2009-01-07 10:43:16 +00:00
Guido Günther
ffafc252dd trivial cleanups 2009-01-06 17:20:27 +00:00
Guido Günther
043d702f02 use virAsprintf instead of asprintf 2008-12-23 13:03:29 +00:00
Guido Günther
5614e868e1 save and remove kvm/qemu domain status 2008-12-20 13:17:49 +00:00
Guido Günther
ecd25f5262 fix device hotplug 2008-12-18 16:49:49 +00:00
Guido Günther
830ba76c3e let qemu/kvm instances write a pid file 2008-12-18 15:22:49 +00:00