Commit Graph

194 Commits

Author SHA1 Message Date
Daniel P. Berrange
85d15b5143 Add support for setting disk drive serial numbers
* docs/schemas/domain.rng: Add <serial> element to disks
* src/domain_conf.h, src/domain_conf.c: XML parsing and
  formatting for disk serial numbers
* src/qemu_conf.c: Set serial number when launching guests
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args,
  tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml: Add
  serial number to XML test
2009-09-03 13:53:34 +01:00
Daniel P. Berrange
d823a05aef Support configuration of huge pages in guests
Add option to domain XML for

     <memoryBacking>
        <hugepages/>
     </memoryBacking>

* configure.in: Add check for mntent.h
* qemud/libvirtd_qemu.aug, qemud/test_libvirtd_qemu.aug, src/qemu.conf
  Add 'hugetlbfs_mount' config parameter
* src/qemu_conf.c, src/qemu_conf.h: Check for -mem-path flag in QEMU,
  and pass it when hugepages are requested.
  Load hugetlbfs_mount config parameter, search for mount if not given.
* src/qemu_driver.c: Free hugetlbfs_mount/path parameter in driver shutdown.
  Create directory for QEMU hugepage usage, chowning if required.
* docs/formatdomain.html.in: Document memoryBacking/hugepages elements
* docs/schemas/domain.rng: Add memoryBacking/hugepages elements to schema
* src/util.c, src/util.h, src/libvirt_private.syms: Add virFileFindMountPoint
  helper API
* tests/qemuhelptest.c: Add -mem-path constants
* tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Add tests for hugepage
  handling
* tests/qemuxml2argvdata/qemuxml2argv-hugepages.xml,
  tests/qemuxml2argvdata/qemuxml2argv-hugepages.args: Data files for
  hugepage tests
2009-09-03 13:51:55 +01:00
Mark McLoughlin
3ec80d0112 Fix bridge/tap system error reporting
* src/qemu_conf.c, src/uml_conf.c: use virReportSystemError() to report
  system errors
2009-08-18 14:15:58 +01:00
Mark McLoughlin
2b1f67d418 Don't expose 'vnet%d' to the user
https://bugzilla.redhat.com/517371

Matt Booth points out that if you use a non-existent bridge name when
start a guest you get a weird error message:

  Failed to add tap interface 'vnet%d' to bridge 'virbr0'

and dev='vnet%d' appears in the dumpxml output.

Fix that by not including 'vnet%d' in the error message and freeing the
'vnet%d' string if adding the tap device to the bridge fails.

* src/qemu_conf.c, src/uml_conf.c: fix qemudNetworkIfaceConnect()
  and umlConnectTapDevice() to not expose 'vnet%d' to the user
2009-08-18 13:36:37 +01:00
Chris Lalancette
2d6a581960 Compressed save image format for Qemu.
Implement a compressed save image format for qemu.  While ideally
we would have the choice between compressed/non-compressed
available to the libvirt API, unfortunately there is no "flags"
parameter to the virDomainSave() API.  Therefore, implement this
as a qemu.conf option.  gzip, bzip2, and lzma are implemented, and
it should be very easy to implement additional compression
methods.

One open question is if/how we should detect the compression
binaries.  One way to do it is to do compile-time setting of the
paths (via configure.in), but that doesn't seem like a great thing
to do.  My preferred solution is not to detect at all;
when we go to run the commands that need them, if they
aren't available, or aren't available in one of the standard paths,
then we'll fail.  That's also the solution implemented in this patch.

In the future, we'll have a more robust (managed) save/restore API,
at which time we can expose this functionality properly in the API.

V2: get rid of redundant dd command and just use >> to append data.
V3: Add back the missing pieces for the enum and bumping the save version.
V4: Make the compressed field in the save_header an int.
    Implement LZMA compression.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-17 09:00:19 +02:00
Mark McLoughlin
d4528d9ac2 Detect KVM's PCI device assignment support
PCI device assignment is only supported in KVM's fork of qemu, so we
should really detect its availability and give a nice error if its
not supported.

* src/qemu_conf.[ch]: introduce QEMUD_CMD_FLAG_PCIDEVICE indicating
  that the -pcidevice command line option is available

* tests/*: update the tests
2009-08-14 08:31:11 +01:00
Aron Griffis
3879b33447 Typo and comment fixes
* docs/schemas/*.rng: the comments were wrong
* src/qemu_conf.c: typo in an error message
2009-08-05 11:56:56 +02:00
Mark McLoughlin
32db8dd75b Make qemuBuildHostNetStr() take tapfd as a string
With hotplug, we're going to want to pass a tapfd name rather than an
actual file descriptor, so prepare the way by passing a string tapfd to
qemuBuildHostNetStr().

* src/qemu_conf.h: qemuBuildHostNetStr() takes a string tapfd now

* src/qemu_conf.c: pass qemuBuildHostNetStr() a string rather than an
  actual file descriptor

* src/qemu_driver.c: update qemudDomainAttachNetDevice() for change
2009-07-27 15:31:51 +01:00
Mark McLoughlin
a3f33b6531 Move vnet_hdr logic into qemudNetworkIfaceConnect() and export it
* src/qemu_conf.h: export qemudNetworkIfaceConnect()

* src/qemu_conf.c: move vnet_hdr logic into qemudNetworkIfaceConnect()
  since we need it for hotplug too
2009-07-27 15:31:51 +01:00
Mark McLoughlin
707302b2cf Only probe qemu for machine types when binary changes
By probing for qemu machine types, we increased the time of a
GetCapabilities call from 100us to a whopping 60ms.

This patch takes the approach of only probing for machine types
when the mtime of the emulator binary changed since the last time
the capabilities were generated.

* src/capabilities.h: cache the emulator binary mtime

* src/qemu_conf.c: add qemudGetOldMachines() to copy the machine
  types from the old caps struct if the mtime for the binary hasn't
  changed

* src/qemu_conf.h, src/qemu_driver.c: pass the old caps pointer to
  qemudCapsInit()
2009-07-27 15:30:35 +01:00
Mark McLoughlin
c14c6b083e Probe QEMU directly for machine aliases if not found in capabilties
Not all possible emulators are actually in the capabilities, so if we
don't find the supplied emulator we should probe it directly for machine
types.

* src/qemu_driver.c: add qemudCanonicalizeMachineDirect() to directly
  probe an emulator for the canonical machine type
2009-07-27 15:17:55 +01:00
Mark McLoughlin
be291b330a Canonicalize qemu machine types
In qemu-0.11 there is a 'pc-0.10' machine type which allows you to run
guests with a machine which is compatible with the pc machine in
qemu-0.10 - e.g. using the original PCI class for virtio-blk and
virtio-console and disabling MSI support in virtio-net. The idea here
is that we don't want to suprise guests by changing the hardware when
qemu is updated.

I've just posted some patches for qemu-0.11 which allows libvirt to
canonicalize the 'pc' machine alias to the latest machine version.

This patches makes us use that so that when a guest is configured to
use the 'pc' machine type, we resolve that to 'pc-0.11' machine and
save that in the guest XML.

See also:

  https://fedoraproject.org/wiki/Features/KVM_Stable_Guest_ABI

* src/qemu_conf.c: add qemudCanonicalizeMachine() to canonicalize
  the machine type according to the machine aliases in capabilities

* src/qemu_driver.c: parse aliases in qemudParseMachineTypesStr()
2009-07-27 15:17:55 +01:00
Mark McLoughlin
38fd207e53 Add virCapsGuestMachine structure
A subsequent commit will add a "canonical" field to this structure,
this patch basically just prepares the way for that.

The new type is added, along with virCapabilitiesAlloc/FreeMachines()
helpers and a whole bunch of code to make the transition.

One quirk is that virCapabilitiesAddGuestDomain() and
virCapabilitiesAddGuest() take ownership of the machine list rather
than duping it. This makes sense to avoid needless copying.

* src/capabilities.h: add the virCapsGuestMachine struct and use it
  in virCapsGuestDomainInfo, add prototypes for new functions and
  update the AddGuest() prototypes

* src/capabilities.c: add code for allocating and freeing the new
  type, change the machines parameter to AddGuest() etc.

* src/libvirt_private.syms: export the new helpers

* src/qemu_conf.c: update all the machine type code to use the new
  struct

* src/xen_internal.c: ditto

* tests/testutilsqemu.c: ditto
2009-07-27 15:17:55 +01:00
Mark McLoughlin
d412487eb7 Probe for QEMU machine types
Currently we hardcode the QEMU machine types. We should really just
parse the output of 'qemu -M ?' so the lists don't get out of sync.

xenner doesn't support '-M ?', so we still need to hardcode that.

The horrible (const char *const *) is removed in a subsequent patch.

* src/qemu_conf.c: kill the arch_info*machines tables, retain the
  hardcoded xenner machine type, add qemudProbeMachineTypes() to
  run and parse 'qemu -M ?' and use it in qemudCapsInitGuest()
2009-07-27 15:17:55 +01:00
Mark McLoughlin
7803e6f3ed Cleanup qemu binary detection logic in qemudCapsInitGuest()
There's no need for the hasbase/hasaltbase confusion, just store the
first binary path found in a variable.

* src/qemu_conf.c: kill hasbase/hasaltbase logic in qemudCapsInitGuest()
2009-07-27 15:17:55 +01:00
Daniel P. Berrange
f4c3acdf35 Make QEMU cgroups use configurable
* qemud/libvirtd_qemu.aug, qemud/test_libvirtd_qemu.aug,
   src/qemu.conf: Add 'cgroups_controllers' and 'cgroups_device_acl'
   parameters
 * src/qemu_conf.h, src/qemu_conf.c: Load & parse configuration params
   for cgroups
 * src/qemu_driver.c: Only use cgroups controllers that are activated,
   and use configured device whitelist instead of default, if set.
2009-07-23 17:38:06 +01:00
Jim Paris
7922e247f1 Always add -no-kvm and -no-kqemu, for qemu domains
If the qemu binary supports "-no-kvm" and/or "-no-kqemu", they should
always be added for plain "qemu" domains.  Previously, we omitted them
whenever the host and guest architectures implied that they would be
disabled automatically, but that logic was flawed in some cases
(such as i686 and x86_64).
* src/qemu_conf.c: fix the conditions for adding "-no-kvm" and/or "-no-kqemu"
2009-07-22 20:51:28 +02:00
Mark McLoughlin
35153940e3 Basic qemu NIC hotplug support
Implement basic NIC hotplug support using the 'host_net_add' and
'pci_add' qemu monitor commands.

For now, we don't support 'bridge' or 'network' types.

Also, if pci_add fails, we currently fail to remove the backend
which we added.

Finally, NIC hot-unplug support is missing.

* src/qemu_driver.c: add qemudDomainAttachNetDevice()

* src/qemu_conf.[ch]: export qemuBuildNicStr(), qemuBuildHostNetStr()
  and qemuAssignNames()

* src/libvirt_private.syms: export virDomainNetTypeToString()
2009-07-22 11:34:06 +01:00
Mark McLoughlin
30605477f2 Store the interface vlan number in the domain state
Currently, an interface's vlan number corresponds to its index in
the table of network interfaces. That is no longer true when we
allow devices to be removed.

To fix this, we store the vlan number in the domain's state XML
so that it survives libvirtd restarts.

* src/domain_conf.h: add vlan number to virDomainNetDef

* src/domain_conf.c: store it in XML as <state vlan='N'/>, defaulting
  to -1 if this is state saved by a previous version of libvirt

* src/qemu_conf.c: assign vlan numbers before starting qemu
2009-07-22 11:34:06 +01:00
Mark McLoughlin
c23dae4e5c Assign names to qemu NICs and network backends
We need these so that we can remove the devices via the monitor.

* src/domain_conf.h: add nic_name and hostnet_name to virDomainNetDef

* src/domain_conf.c: free nic_name and hostnet_name

* src/qemu_conf.c: add qemuAssignNetNames(), use it if qemu has
  support for the param and pass the names on the command line

* tests/qemuxml2argv*: add a test for this
2009-07-22 11:34:06 +01:00
Mark McLoughlin
948897687e Add checks for some NIC hotplug related features added in qemu-0.10.0
Add QEMUD_CMD_FLAG_NET_NAME to indicate that '-net ...,name=foo' is
supported and QEMUD_CMD_FLAG_HOST_NET_ADD to indicate that the
'host_net_add' monitor command is available.

Set both these flags if the qemu version is greater than 0.10.0.
Checking via the '-help' output would not work for the monitor command
and even for the command line arg, it would be quite fragile.

* src/qemu_conf.h: add new flags as aliases of QEMUD_CMD_FLAG_0_10

* src/qemu_conf.c: set QEMUD_CMD_FLAG_0_10 for versions >= 0.10.0

* tests/qemuhelptest.c: set QEMUD_CMD_FLAG_0_10 for the appropriate
  qemu versions
2009-07-22 11:34:06 +01:00
Mark McLoughlin
63e67ee013 Factor qemuBuildHostNetStr() out from qemuBuildCommandLine()
Re-factor this code so that it can be used for NIC hotplug
too. The awkward prefix and type_sep arguments are needed to
allow us to do "host_net_add tap vlan=..."

* src/qemu_conf.c: factor the net backend string formatting
  code into its own function
2009-07-22 11:34:06 +01:00
Mark McLoughlin
ce2e300a4f Factor qemuBuildNicStr() out from qemuBuildCommandLine()
Re-factor this code so that it can be used for NIC hotplug
too. The awkward arguments are needed to allow use to do
"pci_add auto nic macaddr=..."

* src/qemu_conf.c: factor the nic string formatting code into
  its own function
2009-07-22 11:34:06 +01: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
Jim Meyering
07613d2020 remove all trailing blank lines
by running this command:
git ls-files -z | xargs -0 perl -pi -0777 -e 's/\n\n+$/\n/'
This is in preparation for a more strict make syntax-check
rule that will detect trailing blank lines.
2009-07-16 15:06:42 +02: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
Daniel P. Berrange
ad6d5acb42 Support <video> element for QEMU guests
* src/qemu_conf.c, src/qemu_conf.h: Use -vga or -std-vga
	when starting guests if video card is present
	* tests/qemuhelptest.c: Change to use constants instead
	of hardcoded hex numbers, and add VGA support
	* tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl-fullscreen.xml,
	tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args,
	tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml,
	tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.args,
	tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.xml,
	tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.xml,
	tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml,
	tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml: Add <video>
	element for testing graphics adapter
	* tests/qemuxml2argvtest.c: Add QEMUD_CMD_FLAG_VGA flag
	* tests/qemuxml2xmltest.c: Add missing graphics-vnc-sasl/tls tests
2009-07-08 13:40:32 +01:00
Paolo Bonzini
b0e48bfdfe Avoid raising an internal error
* src/qemu_conf.c: when connecting an interface if it reference
  an undefined network, then we used to raise an internal error.
2009-07-07 16:54:55 +02:00
Daniel Veillard
d81275974a Add support for arm emulation if qemu-system-arm is present
* src/qemu_conf.c: patch from C.J. Adams-Collier adding support
  for arm emulation if qemu-system-arm is present
daniel
2009-07-03 13:15:55 +00: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
144276aa1a extend the configuration parser for VMX syntax
* qemud/qemud.c src/conf.c src/conf.h src/qemu_conf.c src/xen_unified.c
  src/xm_internal.c tests/conftest.c tests/xmconfigtest.c: extend
  the configuration parser for VMX syntax, patch by Matthias Bolte
Daniel
2009-06-19 12:34:30 +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
Cole Robinson
3f63c44d12 Add virCapabilities*EmulatorRequired.
Certain drivers always need an 'emulator' specified in the XML (qemu and lxc
at least). Store this info in capabilities.

We will eventually use this to move default emulator handling out of
drivers and into domain_conf.*
2009-06-16 15:27:33 +00:00
Cole Robinson
659bd66529 Check that '-drive format=' is supported before adding to qemu cmdline.
Qemu < 0.10.0 did not support it, and virt-* tools now try to add this by
default, so it's extra important we ensure the option exists.
2009-06-16 15:17:10 +00:00
Cole Robinson
bfb59c172b Fix qemu command flags fetching
New function qemudParseHelpStr was being called with arguments in the
wrong order, so command flags == kvm_version :/
2009-06-16 14:01:43 +00:00
Daniel P. Berrange
56a46886ad Fix re-detection of transient VMs after libvirtd restart 2009-06-12 11:38:50 +00:00
Mark McLoughlin
1fbe229b3c Add qemu help string parsing tests
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-11 14:17:42 +00:00
Mark McLoughlin
04cbe68797 Detect newer qemu-kvm versions
The KVM version string can be one of the following:

  - qemu-kvm-x.y.z in stable releases
  - kvm-XX for kvm versions up to kvm-85
  - qemu-kvm-devel-XX for kvm version kvm-86 and later

There are only a few of places where we need to detect
differences between KVM versions based on 0.9.1:

  1) VNET_HDR introduced in kvm-74

  2) -incoming tcp introduced in kvm-79

  3) -incoming exec introduced in kvm-80

  4) -incoming stdio in all earlier kvm versions

With qemu-kvm-0.10.x, we can now assume that (1) is available
if it's a KVM release, (2) and (3) is always available and
(4) is never available.

So, from now on we should only need to check the qemu version
number and the "is_kvm" flag for detecting feature availability.
We only need the KVM version number for older releases.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-11 14:15:49 +00:00
Mark McLoughlin
56ecebf22d Re-factor qemu version parsing
This patch is purely re-factoring without any functional changes
to make way for the next patch.

The main thing achieved by the refactoring is that we now have
easier access to the parenthesised string that KVM folks seem
to delight in changing.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
2009-06-11 14:12:30 +00:00
Daniel P. Berrange
b0b968efd5 Generic shared impls of all NUMA apis 2009-06-03 13:28:02 +00:00
Daniel Veillard
525c3d40a9 PPC Qemu Machine Type update
* src/qemu_conf.c docs/schemas/domain.rng
  tests/capabilityschemadata/caps-qemu-kvm.xml: PPC Qemu Machine Type
  changed from g3bw to g3beige some time ago, patch by Thomas Baker
Daniel
2009-05-29 13:32:06 +00:00
Daniel P. Berrange
c31300e69f Fix misc bugs in ARGV -> XML convertor 2009-05-28 13:21:19 +00:00
Daniel P. Berrange
2afc3bfd8b Avoid broken networking with new QEMU/KVM >= 86 2009-05-28 13:15:57 +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
3ce55d22e4 Declare support for QEMU migration in capabilities 2009-05-18 15:10:51 +00:00
Daniel P. Berrange
426f9772b8 Fix QEMU ARGV detection with kvm >= 85 2009-05-11 15:14:24 +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
Daniel P. Berrange
88e22e4e8c Enable save/restore/migrate for QEMU >= 0.10.0 2009-05-08 10:07:15 +00:00