Commit Graph

12605 Commits

Author SHA1 Message Date
Taowei
97d8a17bf5 vbox: Rewrite vboxDomainGetState 2014-08-15 09:25:11 +02:00
Taowei
b412975345 vbox: Rewrite vboxDomainGetInfo 2014-08-15 09:25:11 +02:00
Taowei
2cd7a218de vbox: Rewrite vboxDomainSetMemory 2014-08-15 09:25:11 +02:00
Taowei
0ba1c21471 vbox: Rewrite vboxDomainGetOSType 2014-08-15 09:25:11 +02:00
Taowei
40b733e7e2 vbox: Rewrite vboxDomainDestroy 2014-08-15 09:25:11 +02:00
Taowei
25d807d42a vbox: Rewrite vboxDomainDestroyFlags 2014-08-15 09:25:11 +02:00
Taowei
14babb4981 vbox: Rewrite vboxDomainReboot 2014-08-15 09:25:11 +02:00
Taowei
502c43ee44 vbox: Rewrite vboxDomainShutdown 2014-08-15 09:25:11 +02:00
Taowei
67533a8148 vbox: Rewrite vboxDomainShutdownFlags 2014-08-15 09:25:11 +02:00
Taowei
395ecc456e vbox: Rewrite vboxDomainResume 2014-08-15 09:25:11 +02:00
Taowei
8b89505a20 vbox: Rewrite vboxDomainSuspend 2014-08-15 09:25:10 +02:00
Taowei
caba5247fd vbox: Rewrite vboxDomainIsUpdated 2014-08-15 09:25:10 +02:00
Taowei
c9537d13b0 vbox: Rewrite vboxDomainIsPersistent 2014-08-15 09:25:10 +02:00
Taowei
fa2f9abcc1 vbox: Rewrite vboxDomainIsActive 2014-08-15 09:25:10 +02:00
Taowei
2ba3ccbb88 vbox: Rewrite vboxDomainLookupByName 2014-08-15 09:25:10 +02:00
Taowei
856ceb8cb3 vbox: Rewrite vboxDomainCreateXML 2014-08-15 09:25:10 +02:00
Taowei
e979ad3991 vbox: Rewrite vboxDomainCreate 2014-08-15 09:25:10 +02:00
Taowei
815d17398c vbox: Rewrite vboxDomainCreateWithFlags 2014-08-15 09:25:10 +02:00
Taowei
34364df3c6 vbox: Rewrite vboxDomainDefineXML 2014-08-15 09:25:10 +02:00
Taowei
e60e8da4cb vbox: Rewrite vboxDomainUndefineFlags 2014-08-15 09:25:10 +02:00
Taowei
e89a93c071 vbox: Rewrite vboxDomainLookupByUUID 2014-08-15 09:25:10 +02:00
Taowei
9dd4f8eded vbox: Rewrite vboxDomainLookupById 2014-08-15 09:25:10 +02:00
Taowei
5f15b511e9 vbox: Rewrite vboxConnectNumOfDomains 2014-08-15 09:25:10 +02:00
Taowei
0958334ac0 vbox: Rewrite vboxConnectListDomains 2014-08-15 09:25:10 +02:00
Taowei
30a95f30ef vbox: Rewrite vboxConnectGetCapabilities 2014-08-15 09:25:10 +02:00
Taowei
82513be8ba vbox: Rewrite vboxConnectGetMaxVcpus 2014-08-15 09:25:10 +02:00
Taowei
427931ae0c vbox: Rewrite vboxConnectIsAlive 2014-08-15 09:25:10 +02:00
Taowei
16dcbaf09b vbox: Rewrite vboxConnectIsEncrypted 2014-08-15 09:25:10 +02:00
Taowei
3a959b36fd vbox: Rewrite vboxConnectIsSecure 2014-08-15 09:25:10 +02:00
Taowei
86142d8e9a vbox: Rewrite vboxConnectGetHostname 2014-08-15 09:25:09 +02:00
Taowei
6e906ffa91 vbox: Rewrite vboxConnectGetVersion 2014-08-15 09:25:09 +02:00
Taowei
7e052265c9 vbox: Rewrite vboxDomainSave
All vbox objects are child objects from the nsISupports in vbox's
C++ API version. Since the CAPI is generated from the C++ API, I
kept their relationship here, by the definitations below:

typedef struct nsISupports nsISupports;
typedef nsISupports IVirtualBox;
typedef nsISupports ISession;
and so on...

So, when calling the API from nsISupports, we don't need to do
typecasting, and things work still work well.
2014-08-15 09:25:09 +02:00
Taowei
c6084f19d0 vbox: Rewrite vboxConnectClose 2014-08-15 09:25:09 +02:00
Taowei
7f0f415b87 vbox: Begin to rewrite, vboxConnectOpen
Introduce vbox_uniformed_api to deal with version conflicts. Use
vbox_install_api to register the currect vboxUniformedAPI with
vbox version.

vboxConnectOpen has been rewritten.
2014-08-15 09:25:09 +02:00
Laine Stump
7809615056 network: fix crash when starting a network with no <pf> element
Martin Kletzander pointed out in email that my commit 2a193f64
introduced a crash in networkCreateInterfacePool() during startup of
any network that doesn't have a <pf> subelement of its <forward>
element. He also supplied a patch.

 http://www.redhat.com/archives/libvir-list/2014-August/msg00655.html

I expanded on that patch by cleaning up now-extraneous checks in the
callers of networkCreateInterfacePool().

Fortunately the offending patch hasn't been in any release, and hasn't
been (to my knowledge) backported to any other branch.
2014-08-15 02:42:52 -04:00
Jim Fehlig
62c817e516 src/xenxs: Refactor code formating vif device config
Handle formating of VIF config in a new function xenFormatXMVif().

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-14 11:49:53 -06:00
Kiarie Kahurani
2e2ac1ed4a src/xenxs: Refactor code formating peripheral device config
introduce functions
  xenFormatXMSound
  xenFormatXMInputDevs(virConfPtr conf,....);
which formats peripheral device config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-14 11:49:53 -06:00
Kiarie Kahurani
a54b4144fb src/xenxs: Refactor code formating Vfb config
introduce function
   xenFormatXMVfb(virConfPtr conf,.........);
which formats Vfb config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-14 11:49:53 -06:00
Kiarie Kahurani
5c5cac8ced src/xenxs: Refactor code formating OS config
introduce functions
   xenFormatXMEmulator(virConfPtr conf,........);
   xenFormatXMCDROM(virConfPtr conf, .......);
   xenFormatXMOS(virConfPtr conf,........);
which formats OS and associated config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-08-14 11:49:53 -06:00
Kiarie Kahurani
208660e046 src/xenxs: Refactor code formating CPU config
introduce functions
  xenFormatXMCPUAllocation(virConfPtr conf, ......);
  xenFormatXMCPUFeatures(virConfPtr conf, ......);
which formats CPU allocation and features config

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-08-14 11:49:53 -06:00
Kiarie Kahurani
f8ad0198a1 src/xenxs: Refactor code formating xm disk config
introduce function
  xenFormatXMDisks(virConfPtr conf,.........);
which formats domain disks config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-08-14 11:49:53 -06:00
Kiarie Kahurani
5dde1629fb src/xenxs: Refactor code formating Char devices config
introduce function
   xenFormatXMCharDev(virConfPtr conf,........);
which formats Char devices config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-08-14 11:49:53 -06:00
Kiarie Kahurani
c849d01c5e src/xenxs: Refactor code formating event actions config
introduce function
   xenFormatXMEventActions(virConfPtr conf,.........);
which formats event actions instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-14 11:49:53 -06:00
Kiarie Kahurani
a7de003a94 src/xenxs: Refactor code formating virtual time config
introduce function
  xenFormatXMTimeOffset(virConfPtr conf,........);
which formats time config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-08-14 11:49:53 -06:00
Kiarie Kahurani
8faab08c14 src/xenxs: Refactor code formating memory config
introduce function
   xenFormatXMMem(virConfPtr conf,...........);
which parses memory config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-14 11:49:52 -06:00
Kiarie Kahurani
44650e91b9 src/xenxs: Refactor code formating general VM config
introduce function
  xenFormatXMGeneralMeta(virConfPtr conf,......);
which parses uuid and name instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2014-08-14 11:49:52 -06:00
Pavel Hrdina
0c35a415f7 qemu_process: fix memleak found by coverity
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-08-14 19:33:06 +02:00
Richard Weinberger
41885a0224 LXC: Fix virLXCControllerSetupDevPTS() wrt user namespaces
The gid value passed to devpts has to be translated by hand as
virLXCControllerSetupDevPTS() is called before setting up the user
and group mappings.
Otherwise devpts will use an unmapped gid and openpty()
will fail within containers.
Linux kernel commit 23adbe12
("fs,userns: Change inode_capable to capable_wrt_inode_uidgid")
uncovered that issue.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-08-14 14:32:49 +02:00
Sam Bobroff
f0f9eed843 qemu: Tidy up job handling during live migration
During a QEMU live migration several warning messages about job
handling could be written to syslog on the destination host:

"entering monitor without asking for a nested job is dangerous"

The messages are written because the job handling during migration
uses hard coded asyncJob values in several places that are incorrect.

This patch passes the required asyncJob value around and prevents
the warnings as well as any issues that the warnings may be referring
to.

https://bugzilla.redhat.com/show_bug.cgi?id=1130089

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-08-14 12:12:42 +02:00
Mo yuxiang
ca8ef1df3b conf: fix parsing 'cmd_per_lun' and 'max_sectors'
commit d9504941 introduces two new attributes "cmd_per_lun" and
"max_sectors" same with the names QEMU uses for virtio-scsi.
But the case of parsing them is not exact. Change to parse
them if controller has "driver" element.

Signed-off-by: Mo yuxiang <moyuxiang@huawei.com>
2014-08-14 10:25:57 +02:00
Chen Hanxiao
bd3b76e355 LXC: resolve issues in lxcDomainSetMaxMemory
This patch changes the setmaxmem function to support the '--live',
'--config', and '--current' flags by revectoring the code through
the setmem function using the VIR_DOMAIN_MEM_MAXIMUM flag. The
setmem code is refactored to handle both cases depending on the flag.

The changed maxmem code for the MEM_MAXIMUM path will not allow
modification to the memory values of an active guest unless the --config
switch is used.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2014-08-13 17:40:28 -04:00
Eric Blake
b50c8603a2 maint: improve syntax check for space around =
Laine Stump noted on IRC that syntax check wasn't flagging his
typo of 'i= 0'.  This fixes it.

* build-aux/bracket-spacing.pl: Tighten 'space around =' rule.
* src/storage/storage_backend.c
(virStorageBackendCreateExecCommand): Fix offenders.
* src/util/virnuma.c (virNumaGetDistances): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSnapshotDeleteMetadataOnly)
(vboxNetworkGetXMLDesc): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainLookupByName):
Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-12 11:21:17 -06:00
Dmitry Guryanov
aad6e85f25 bhyve: fix error message in bhyveStateInitialize
If we failed to create BHYVE_STATE_DIR, we should show this
path, not BHYVE_LOG_DIR.
2014-08-12 21:12:19 +04:00
Michal Privoznik
bf4cbe4094 qemu_conf: Undefine the correct symbol
At the beginning of the qemu config file parsing function there
are 3 helper macros defined: GET_VALUE_BOOL, GET_VALUE_LONG and
GET_VALUE_STR. Later, when they are no longer needed they are
undefined in order to keep the namespace clean. However, the
GET_VALUE_STRING is undefined instead of GET_VALUE_STR.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-12 17:45:43 +02:00
Roman Bogorodskiy
0257d06ba4 storage: ZFS support
Implement ZFS storage backend driver. Currently supported
only on FreeBSD because of ZFS limitations on Linux.

Features supported:

 - pool-start, pool-stop
 - pool-info
 - vol-list
 - vol-create / vol-delete

Pool definition looks like that:

 <pool type='zfs'>
  <name>myzfspool</name>
  <source>
    <name>actualpoolname</name>
  </source>
 </pool>

The 'actualpoolname' value is a name of the pool on the system,
such as shown by 'zpool list' command. Target makes no sense
here because volumes path is always /dev/zvol/$poolname/$volname.

User has to create a pool on his own, this driver doesn't
support pool creation currently.

A volume could be used with Qemu by adding an entry like this:

    <disk type='volume' device='disk'>
      <driver name='qemu' type='raw'/>
      <source pool='myzfspool' volume='vol5'/>
      <target dev='hdc' bus='ide'/>
    </disk>
2014-08-12 19:40:20 +04:00
Peter Krempa
1b7c2c549e qemu: migration: Check domain live state after exitting the monitor
In qemuMigrationToFile we enter the monitor multiple times and don't
check if the VM is still alive after returning form the monitor. Add the
checks to skip pieces of code in case the VM crashes while saving it's
state.
2014-08-12 17:32:28 +02:00
Peter Krempa
3fe9f61d54 qemu: managedsave: Check that VM is alive after entering async job
Saving a shutoff VM doesn't make sense and libvirtd crashes while
attempting to do that. Check that the domain is alive after entering
the save async job.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1129207
2014-08-12 17:31:37 +02:00
Peter Krempa
e3f5af6a5f qemu: process: Fix header format of qemuProcessSetVcpuAffinities
Fix header alignment and remove the unused conn parameter.
2014-08-12 17:24:34 +02:00
Erik Skultety
983f5a5076 numatune: Fix parsing of empty nodeset (0,^0)
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1121837
2014-08-12 17:04:31 +02:00
Michal Privoznik
3085702b54 conf: Format interface's driver more frequently
https://bugzilla.redhat.com/show_bug.cgi?id=1128751

There's this <driver/> element under <interface/> which can have
several attributes. However, the driver element is currently formated
only if the driver's name or txmode has been specified. This makes
only a little sense as we parse even partial <driver/>, for instance:

    <interface type='user'>
      <mac address='52:54:00:e5:48:58'/>
      <model type='virtio'/>
      <driver ioeventfd='on' event_idx='on' queues='5'/>
    </interface>

But such XML would never get formatted back.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-12 09:29:10 +02:00
Laine Stump
2a193f6458 network: populate interface pool immediately when network is started
When a network is defined with "<pf dev='xyz'/>", libvirt will query
sysfs to learn the list of all virtual functions (VF) associated with
that Physical Function (PF) then populate the network's interface pool
accordingly. This action was previously done only when the first guest
actually requested an interface from the network. This patch changes
it to populate the pool immediately when the network is started. This
way any problems with the PF or its VFs will become apparent sooner.

Note that we can't remove the old calls to networkCreateInterfacePool
that happen whenever a guest requests an interface - doing so would be
asking for failures on hosts that had libvirt upgraded with a network
that had been started but not yet used.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1047818
2014-08-11 17:34:28 -04:00
Laine Stump
cd7759cb96 network: make networkCreateInterfacePool more robust
networkCreateInterfacePool was a bit loose in its error cleanup, which
could result in a network definition with interfaces in the pool that
were NULL. This would in turn lead to a libvirtd crash when a guest
tried to attach an interface using the network with that pool.

In particular this would happen when creating a pool to be used for
macvtap connections. macvtap needs the netdev name of the virtual
function in order to use it, and each VF only has a netdev name if it
is currently bound to a network driver. If one of the VFs of a PF
happened to be bound to the pci-stub or vfio-pci driver (indicating
it's already in use for PCI passthrough), or no driver at all, it
would have no name. In this case networkCreateInterfacePool would
return an error, but would leave the netdef->forward.nifs set to the
total number of VFs in the PF. The interface attach that triggered
calling of networkCreateInterfacePool (it uses a "lazy fill" strategy)
would simply fail, but the very next attempt to attach an interface
using the same network pool would result in a crash.

This patch refactors networkCreateInterfacePool to bring it more in
line with current coding practices (label name, use of a switch with
no default case) as well as providing the following two changes to
behavior:

1) If a VF with no netdev name is encountered, just log a warning and
continue; only fail if exactly 0 devices are found to put in the pool.

2) If the function fails, clean up any partial interface pool and set
netdef->forward.nifs to 0.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1111455
2014-08-11 17:34:20 -04:00
Guido Günther
ee2a7c5483 Don't fail qemu driver intialization if we can't determine hugepage size
Otherwise we fail like

  libvirt version: 1.2.7, package: 6 (root 2014-08-08-16:09:22 bogon)
  virAuditOpen:62 : Unable to initialize audit layer: Protocol not supported
  virFileGetDefaultHugepageSize:2958 : internal error: Unable to parse /proc/meminfo
  virStateInitialize:749 : Initialization of QEMU state driver failed: internal error: Unable to parse /proc/meminfo
  daemonRunStateInit:922 : Driver state initialization failed

if the data can't be determined.

Reference: http://bugs.debian.org/757609
2014-08-11 22:23:48 +02:00
Guido Günther
712374d15f Include param.h in case of HAVE_BSD_CPU_AFFINITY
This fixes compilation on kFreeBSD which otherwise fails like

  CC       util/libvirt_util_la-virprocess.lo
In file included from /usr/include/sys/cpuset.h:35:0,
                 from util/virprocess.c:43:
/usr/include/sys/_cpuset.h:49:43: error: 'NBBY' undeclared here (not in
a function)
  long __bits[howmany(CPU_SETSIZE, _NCPUBITS)];
                                           ^
In file included from util/virprocess.c:43:0:
/usr/include/sys/cpuset.h:215:12: error: unknown type name 'cpusetid_t'
 int cpuset(cpusetid_t *);
            ^
/usr/include/sys/cpuset.h:216:30: error: expected ')' before 'id_t'
 int cpuset_setid(cpuwhich_t, id_t, cpusetid_t);
                              ^
/usr/include/sys/cpuset.h:217:42: error: expected ')' before 'id_t'
 int cpuset_getid(cpulevel_t, cpuwhich_t, id_t, cpusetid_t *);
                                          ^
/usr/include/sys/cpuset.h:218:48: error: expected ')' before 'id_t'
 int cpuset_getaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, cpuset_t
*);
                                                ^
/usr/include/sys/cpuset.h:219:48: error: expected ')' before 'id_t'
 int cpuset_setaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, const
cpuset_t *);

And it's the correct usage as documented in

  http://www.freebsd.org/cgi/man.cgi?query=cpuset_setid

Also change the #ifdef HAVE_BSH_CPU_AFFINITY to #if for consistency.
2014-08-11 22:23:48 +02:00
Tomoki Sekiyama
09dbb47832 qemu: use guest-fsfreeze-freeze-list command if mountpoints to freeze specified
A command to freeze a part of mounted file systems is implemented in
upstream QEMU-guest-agent with a name of 'guest-fsfreeze-freeze-list'.
This fixes the name of the command used to partial fsfreeze in qemu driver
when 'mountpoints' option is specified to virDomainFSFreeze API.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
2014-08-11 12:11:41 +02:00
Jianwei Hu
337c6eec1b qemu: Actually clear bandwidth settings
The virDomainSetInterfaceParameters implementation in qemu over
VIR_DOMAIN_AFFECT_CONFIG doesn't work as expected. When trying to
clear out the bandwidth settings for an interface, it has no
actual effect:

    virsh # domiftune --config $domain $interface
    inbound.average: 100
    inbound.peak   : 0
    inbound.burst  : 0
    outbound.average: 10
    outbound.peak  : 0
    outbound.burst : 0

    virsh domiftune --config $domain $interface 0 0

    virsh # domiftune --config $domain $interface
    inbound.average: 100
    inbound.peak   : 0
    inbound.burst  : 0
    outbound.average: 10
    outbound.peak  : 0
    outbound.burst : 0

But according to virsh man page:

    To clear inbound or outbound settings, use --inbound or
    --outbound respectfully with average value of zero.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-11 11:56:58 +02:00
Kiarie Kahurani
954538720d src/xenxs: Refactor code parsing OS config
introduce function
  xenParseXMOS(virConfPtr conf,...........);
which parses the OS config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 15:41:17 -06:00
Kiarie Kahurani
24543c6571 src/xenxs: Refactor code parsing general config
introduce function
   xenParseXMGeneralMeta(virConfPtr conf, .......);
which parses general metadata instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 15:41:03 -06:00
Kiarie Kahurani
3631f5dfc6 src/xenxs: Refactor code parsing emulated hardware config
introduce function
   xenParseXMEmulatedHardware(virConfPtr conf,.........);
which parses emulated devices config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 15:20:59 -06:00
Kiarie Kahurani
4821c32c94 src/xenxs: Refactor code parsing Vif config
introduce function
  xenParseXMVif(virConfPtr conf,........);
which parses Vfb config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 15:20:59 -06:00
Kiarie Kahurani
aa964890cb src/xenxs: Refactor code parsing Char devices config
introduce function
  xenParseXMCharDev(virConfPtr conf,.........);
which parses Char devices config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 15:20:59 -06:00
Kiarie Kahurani
f4f9eae128 src/xenxs: Refactor code parsing Vfb config
introduce function
 xenParseXMVfb(virConfPtr conf,..........);
which parses Vfb config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 15:20:59 -06:00
Kiarie Kahurani
70328f6cc8 src/xenxs: Refactor code parsing xm disk config
introduce function
  xenParseXMDisk(virConfPtr conf, ........);
which parses xm disk config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 15:20:41 -06:00
Kiarie Kahurani
fc953fcfc0 src/xenxs: Refactor code parsing CPU features
introduce function
  xenParseXMCPUFeatures(virConfPtr conf,.........);
which parses CPU features instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 11:41:40 -06:00
Kiarie Kahurani
d8c6207039 src/xenxs: Refactor code parsing PCI config
introduce function
   xenParseXMPCI(virConfPtr conf, ........);
which parses PCI config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 11:38:50 -06:00
Kiarie Kahurani
b1948c525e src/xenxs: Refactor code parsing event actions
introduce function
  xenParseXMEventActions(virConfPtr conf,........)
which parses events leading to certain actions

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 11:35:37 -06:00
Kiarie Kahurani
1182dc3176 src/xenxs: Refactor code parsing virtual time config
introduce function
    xenParseXMTimeOffset(virConfPtr conf,.......);
which parses time offset config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 11:32:15 -06:00
Kiarie Kahurani
52c048b1f0 src/xenxs: Refactor code parsing memory config
introduce function
  xenParseXMMem(virConfPtr conf,.........);
which parses memory config instead

Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com>
2014-08-08 11:24:09 -06:00
Peter Krempa
e260a0e60a conf: Add USB sound card support and implement it for qemu 2014-08-08 14:34:20 +02:00
John Ferlan
2e194e5bcc qemu: Remove extraneous space in function prototypes
During review of the iSCSI hostdev series, eblake noted that the
prototypes shouldn't have the extranenous space between the "*" and
the function name:

http://www.redhat.com/archives/libvir-list/2014-July/msg01227.html

Since it was more invasive than 1 or 2 lines - I said I'd send a
patch covering this once committed.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2014-08-07 15:07:56 -04:00
John Ferlan
54ac483e68 hostdev: Add iSCSI hostdev XML
Introduce a new structure to handle an iSCSI host device based on the
existing virDomainHostdevSubsysSCSI by adding a "protocol='iscsi'" to
the <source/> element. The existing scsi_host subsystem RNG was modified
to read an optional "protocol='adapter'", although it won't be written
out nor is it documented as an option (by choice).

The new hostdev structure mimics the existing <disk/> element for an
iSCSI device (network) device. New XML is:

  <hostdev mode='subsystem' type='scsi' managed='yes'>
    <source protocol='iscsi' name='iqn.1992-01.com.example'>
      <host name='example.org' port='3260'/>
      <auth username='myname'>
        <secret type='iscsi' usage='mycluster_myname'/>
      </auth>
    </source>
    <address type='drive' controller='0' bus='0' target='2' unit='5'/>
  </hostdev>

The controller element will mimic the existing scsi_host code insomuch
as when 'lsi' and 'virtio-scsi' are used.
2014-08-07 15:07:56 -04:00
John Ferlan
c3f4942939 domain_conf: Common routine to handle network storage host xml def
In preparation for hostdev support for iSCSI and a virStorageNetHostDefPtr,
split out the network disk storage parsing of the 'host' element into a
separate routine.
2014-08-07 15:07:56 -04:00
Eric Blake
265680c58e blockjob: fix use-after-free in blockcopy
Commit febf84c2 tried to delay in-memory modification of the actual
domain disk structure until after the qemu event was received.
However, I missed that the code for block pivot had been temporarily
setting disk->src = disk->mirror prior to the qemu command, in order
to label the backing chain of a reused external blockcopy disk;
and calls into qemu while still in that state before finally undoing
things at the cleanup label.  Since the qemu event handler then does:
 virStorageSourceFree(disk->src);
 disk->src = disk->mirror;
we have the sad race that a fast enough qemu event can cause a leak of
the original disk->src, as well as a use-after-free of the disk->mirror
contents, bad enough to crash libvirtd in some of my test runs, even
though the common case of the qemu event being much later won't trip
the race.

I'll go wear the brown paper bag of shame, for introducing a crasher
in between rc1 and rc2 of the freeze for 1.2.7 :(  My only
consolation is that virDomainBlockJobAbort requires the domain:write
ACL, so it is not a CVE.

The valgrind report when the race occurs looks like:

==25612== Invalid read of size 4
==25612==    at 0x50E7C90: virStorageSourceGetActualType (virstoragefile.c:1948)
==25612==    by 0x209C0B18: qemuDomainDetermineDiskChain (qemu_domain.c:2473)
==25612==    by 0x209D7F6A: qemuProcessHandleBlockJob (qemu_process.c:1087)
==25612==    by 0x209F40C9: qemuMonitorEmitBlockJob (qemu_monitor.c:1357)
...
==25612==  Address 0xe4b5610 is 0 bytes inside a block of size 200 free'd
==25612==    at 0x4A07577: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25612==    by 0x50839E9: virFree (viralloc.c:582)
==25612==    by 0x50E7E51: virStorageSourceFree (virstoragefile.c:2015)
==25612==    by 0x209D7EFF: qemuProcessHandleBlockJob (qemu_process.c:1073)
==25612==    by 0x209F40C9: qemuMonitorEmitBlockJob (qemu_monitor.c:1357)

* src/qemu/qemu_driver.c (qemuDomainBlockPivot): Don't corrupt
disk->src, and only label chain for blockcopy.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-07 12:17:02 -06:00
Eric Blake
a595a00572 blockjob: avoid memory leak during block pivot
Valgrind caught a memory leak:

==2018== 9 bytes in 1 blocks are definitely lost in loss record 143 of 927
==2018==    at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==2018==    by 0x8C42369: strdup (strdup.c:42)
==2018==    by 0x50EACC9: virStrdup (virstring.c:676)
==2018==    by 0x50E79E5: virStorageSourceCopy (virstoragefile.c:1845)
==2018==    by 0x20A3FAA7: qemuDomainBlockCommit (qemu_driver.c:15620)
==2018==    by 0x51DC6B2: virDomainBlockCommit (libvirt.c:20092)

I traced it to the fact that blockcopy and blockcommit end up
reparsing a backing chain on pivot, but the chain parsing code
doesn't gracefully handle the case where the backing file is
already known.

I'm not exactly sure when this was introduced, but suspect that the
refactoring in commit 9944b71 and friends that moved towards probing
in-place rather than into a temporary structure are part of the cause.

* src/util/virstoragefile.c (virStorageFileGetMetadataInternal):
Don't leak any prior value.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-07 12:17:02 -06:00
Wang Rui
ace06985df audit: Fix some comments
Fix a comment in virDomainAuditNetDevice.
Fix a typo in comment of qemuPhysIfaceConnect which is
the caller of virDomainAuditNetDevice.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
2014-08-07 10:28:32 +02:00
Peter Krempa
29bb066915 snapshot: conf: Enforce absolute paths on disk and memory images
RNG schema as well as the qemu driver requires absolute paths for memory
and disk snapshot image files but the XML parser was not enforcing it.
Add checks to avoid problems in qemu where the configuration it creates
is invalid.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1126329
2014-08-06 17:58:26 +02:00
Michal Privoznik
d26e810838 qemu: Make virFileFindHugeTLBFS fault tolerant
Since commit be0782e1 we are parsing /proc/meminfo to find out the
default huge page size. However, if the host we are running at does
not support any huge pages (e.g. CONFIG_HUGETLB_PAGE is turned off),
we will not successfully parse the meminfo file and hence the whole
qemu driver init process fails. Moreover, the default huge page size
is needed if and only if there's at least one hugetlbfs mount point.
So the fix consists of moving the virFileGetDefaultHugepageSize
function call after the first hugetlbfs mount point is found.

With this fix, we fail to start with one or more hugetlbfs mounts and
malformed meminfo file, but that's expected (how can one mount
hugetlbfs without kernel supporting huge pages?). Workaround in that
case is to umount all the hugetlbfs mounts.

Reported-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-08-06 17:31:08 +02:00
Prerna Saxena
8d4740c1b0 Node Devices: Fix nodedev-list for fc_host & vports.
In a system with Fiber Channel Host Adapters, a query to list all Fibre Channel
HBAs OR Vports currently returns empty list:
  $ virsh nodedev-list --cap fc_host

  $

Libvirt correctly discovers properties for all HBAs. However, the reporting
fails because of incorrect flag comparison while filtering these types.

This is fixed by removing references to 'VIR_CONNECT_LIST_NODE_DEVICES_CAP_*'
for comparison and replacing those with 'VIR_NODE_DEV_CAP_*'

Introduced by original commit id '652a2ec6'

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
2014-08-06 07:45:45 -04:00
Martin Kletzander
4eb8984683 qemu: reword caps-related error
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-06 06:38:04 +02:00
Eric Blake
e8cc973041 blockjob: correctly report active commit for job info
Commit 232a31b munged job info to report 'active commit' instead of
'commit' when generating events, but forgot to also munge the polling
variant of the command.

* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust type as
needed.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-05 10:30:56 -06:00
Ján Tomko
6dac5d06f5 Don't overwrite errors from virNetDevBandwidthSet
Otherwise this beautiful error would be overwritten when
the function is called with a really high rate number:

2014-07-28 12:51:47.920+0000: 2304: error : virCommandWait:2399 :
internal error: Child process (/sbin/tc class add dev vnet0 parent 1:
classid 1:1 htb rate 4294968kbps) unexpected exit status 1: Illegal "rate"
Usage: ... qdisc add ... htb [default N] [r2q N]
 default  minor id of class to which unclassified packets are sent {0}
 r2q      DRR quantums are computed as rate in Bps/r2q {10}
 debug    string of 16 numbers each 0-3 {0}

... class add ... htb rate R1 [burst B1] [mpu B] [overhead O]
                      [prio P] [slot S] [pslot PS]
                      [ceil R2] [cburst B2] [mtu MTU] [quantum Q]
 rate     rate allocated to this class (class can still borrow)
 burst    max bytes burst which can be accumulated during idle period {computed}
 mpu      minimum packet size used in rate computations
 overhead per-packet size overhead used in rate computations
 linklay  adapting to a linklayer e.g. atm
 ceil     definite upper class rate (no borrows) {rate}
 cburst   burst but for ceil {computed}
 mtu      max packet size we create rate map for {1600}
 prio     priority of leaf; lowe

https://bugzilla.redhat.com/show_bug.cgi?id=1043735
2014-08-04 16:59:28 +02:00
John Ferlan
4a85bf3e2f storage: Refresh storage pool after upload
https://bugzilla.redhat.com/show_bug.cgi?id=1072653

Upon successful upload of a volume, the target volume and storage pool
were not updated to reflect any changes as a result of the upload. Make
use of the existing stream close callback mechanism to force a backend
pool refresh to occur in a separate thread once the stream closes. The
separate thread should avoid potential deadlocks if the refresh needed
to wait on some event from the event loop which is used to perform
the stream callback.
2014-08-04 10:35:52 -04:00
Martin Kletzander
b2574b4719 qemu: fix comment in qemu.conf
There are multiple mount points after commit 725a211f, but one comment
wasn't changed to use plurals.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-08-04 07:53:55 +02:00
Eric Blake
478d93ad1f build: fix build on cygwin
Cygwin has getifaddrs(), but not AF_LINK, leading to:

util/virstats.c: In function 'virNetInterfaceStats':
util/virstats.c:138:41: error: 'AF_LINK' undeclared (first use in this function)
         if (ifa->ifa_addr->sa_family != AF_LINK)
...

* src/util/virstats.c (virNetInterfaceStats): Only use getifaddrs
if AF_LINK is present.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-08-02 20:52:34 -06:00
Laine Stump
c0788af07d network: always set disable_ipv6, even when it should be 0
libvirt previously only touched an interface's disable_ipv6 setting in
sysfs if it needed to be set to 1, assuming that 0 is the
default. Apparently that isn't always the case though (kernel 3.15.7-1
in Arch Linux reportedly defaults a new interface's disable_ipv6
setting to 1) so this patch explicitly sets it to 0 or 1 as
appropriate.
2014-08-02 21:51:24 -04:00
Ján Tomko
be3cbecd0e Fix a crash when cloning a volume with no backing store
Introduced by commit 15213d1, not yet released.
2014-08-01 15:42:28 +02:00
Eric Blake
cfb16b8ed7 blockcommit: turn on active commit
With this in place, I can (finally!) now do:

virsh blockcommit $dom vda --shallow --verbose --pivot

and watch qemu shorten the backing chain by one, followed by
libvirt automatically updating the dumpxml output, effectively
undoing the work of virsh snapshot-commit --no-metadata --disk-only.
Commit is SOOOO much faster than blockpull, when I'm still fairly
close in time to when the temporary qcow2 wrapper file was created
via a snapshot operation!

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Implement live
commit.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-30 06:32:39 -06:00
Eric Blake
232a31bea3 blockcommit: track job type in xml
A future patch is going to wire up qemu active block commit jobs;
but as they have similar events and are canceled/pivoted in the
same way as block copy jobs, it is easiest to track all bookkeeping
for the commit job by reusing the <mirror> element.  This patch
adds domain XML to track which job was responsible for creating a
mirroring situation, and adds a job='copy' attribute to all
existing uses of <mirror>.  Along the way, it also massages the
qemu monitor backend to read the new field in order to generate
the correct type of libvirt job (even though it requires a
future patch to actually cause a qemu event that can be reported
as an active commit).  It also prepares to update persistent XML
to match changes made to live XML when a copy completes.

* docs/schemas/domaincommon.rng: Enhance schema.
* docs/formatdomain.html.in: Document it.
* src/conf/domain_conf.h (_virDomainDiskDef): Add a field.
* src/conf/domain_conf.c (virDomainBlockJobType): String conversion.
(virDomainDiskDefParseXML): Parse job type.
(virDomainDiskDefFormat): Output job type.
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Distinguish
active from regular commit.
* src/qemu/qemu_driver.c (qemuDomainBlockCopy): Set job type.
(qemuDomainBlockPivot, qemuDomainBlockJobImpl): Clean up job type
on completion.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml:
Update tests.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-disk-active-commit.xml: New
file.
* tests/qemuxml2xmltest.c (mymain): Drive new test.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-30 06:32:38 -06:00
Cédric Bosdonnat
251d75a863 Domain config: write <features/> if some capabilities are set.
If all features are set to default (including the capabilities policy),
but some capabilities are toggled, we need to output the <features>
element when formatting the config.
2014-07-30 14:21:55 +02:00
Eric Blake
febf84c26a blockjob: properly track blockcopy xml changes on disk
We were not directly saving the domain XML to file after starting
or finishing a blockcopy.  Without the startup write, a libvirtd
restart in the middle of a copy job would forget that the job was
underway.  Then at pivot, we were indirectly writing new XML in
reaction to events that occur as we stop and restart the guest CPUs.
But there was a race: since pivot is an async action, it is possible
that libvirtd is restarted before the pivot completes, so if XML
changes during the event, that change was not written.  The original
blockcopy code cleared out the <mirror> element prior to restarting
the CPUs, but this is also a race, observed if a user does an async
pivot and a dumpxml before the event occurs.  Furthermore, this race
will interfere with active commit in a future patch, because that
code will rely on the <mirror> element at the time of the qemu event
to determine whether to inform the user of a normal commit or an
active commit.

Fix things by saving state any time we modify live XML, while
delaying XML disk modifications until after the event completes.  We
still need a to teach libvirtd restarts to examine all existing
<mirror> elements to see if the job completed in the meantime (that
is, if libvirtd misses the event, the updated state still needs to be
updated in live XML), but that will be a later patch, in part because
we also need to to start taking advantage of newer qemu's ability to
keep the job around after completion rather than the current usage
where the job disappears both on error and on success.

* src/qemu/qemu_driver.c (qemuDomainBlockCopy): Track XML change
on disk.
(qemuDomainBlockJobImpl, qemuDomainBlockPivot): Move job-end XML
rewrites...
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): ...here.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-29 15:36:30 -06:00
Eric Blake
9a212d6708 blockcopy: add more XML for state tracking
Doing a blockcopy operation across a libvirtd restart is not very
robust at the moment.  In particular, we are clearing the <mirror>
element prior to telling qemu to finish the job.  Also, thanks to the
ability to request async completion, the user can easily regain
control prior to qemu actually finishing the effort, and they should
be able to poll the domain XML to see if the job is still going.

A future patch will fix things to actually wait until qemu is done
before modifying the XML to reflect the job completion.  But since
qemu issues identical BLOCK_JOB_COMPLETE events regardless of whether
the job was cancelled (kept the original disk) or completed (pivoted
to the new disk), we have to track which of the two operations were
used to end the job.  Furthermore, we'd like to avoid attempts to
end a job where we are already waiting on an earlier request to qemu
to end the job.  Likewise, if we miss the qemu event (perhaps because
it arrived during a libvirtd restart), we still need enough state
recorded to be able to determine how to modify the domain XML once
we reconnect to qemu and manually learn whether the job still exists.

Although this patch doesn't actually fix the problem, it is a
preliminary step that makes it possible to track whether a job
has already begun steps towards completion.

* src/conf/domain_conf.h (virDomainDiskMirrorState): New enum.
(_virDomainDiskDef): Convert bool mirroring to new enum.
* src/conf/domain_conf.c (virDomainDiskDefParseXML)
(virDomainDiskDefFormat): Handle new values.
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Adjust
client.
* src/qemu/qemu_driver.c (qemuDomainBlockPivot)
(qemuDomainBlockJobImpl): Likewise.
* docs/schemas/domaincommon.rng (diskMirror): Expose new values.
* docs/formatdomain.html.in (elementsDisks): Document it.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-29 15:36:30 -06:00
Hu Tao
c5b02b6773 qemu: error out if PCI passthrough type is not supported
If PCI passthrough type is not supported, we should error out rather than
continue building the command line.

When starting a domain, the type has been already checked by
qemuPrepareHostdevPCICheckSupport() before building qemu command line,
so the problem doesn't emerge.

But when coverting a domain xml without specifying passthrough type explictly
to qemu arg, we will get a malformed command line.

the xml:

    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0001' bus='0x03' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </hostdev>

the converted command line:

  -device ,host=0001:03:00.0,id=hostdev0,bus=pci.0,addr=0x5

After this patch, virsh gives an error message:

  virsh domxml-to-native qemu-argv /tmp/tmp.xml
  error: internal error: invalid PCI passthrough type 'default'

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-07-29 15:35:08 +02:00
Michal Privoznik
3517e1b2f2 qemu: Implement ./hugepages/page/[@size, @unit, @nodeset]
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-07-29 12:14:52 +01:00
Michal Privoznik
136ad49740 domain: Introduce ./hugepages/page/[@size, @unit, @nodeset]
<memoryBacking>
    <hugepages>
      <page size="1" unit="G" nodeset="0-3,5"/>
      <page size="2" unit="M" nodeset="4"/>
    </hugepages>
  </memoryBacking>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-07-29 12:02:34 +01:00
Michal Privoznik
49baed2b29 virbitmap: Introduce virBitmapOverlaps
This internal API just checks if two bitmaps intersect or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-07-29 12:00:42 +01:00
Michal Privoznik
725a211fc0 qemu: Utilize virFileFindHugeTLBFS
Use better detection of hugetlbfs mount points. Yes, there can be
multiple mount points each serving different huge page size.

Since we already have ability to override the mount point in the
qemu.conf file, this crazy backward compatibility code is brought in.
Now we allow multiple mount points, so the "hugetlbfs_mount" option
must take an list of strings (mount points). But previously, it was
just a string, so we must accept both types now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-07-29 11:58:35 +01:00
Michal Privoznik
be0782e199 Introduce virFileFindHugeTLBFS
This should iterate over mount tab and search for hugetlbfs among with
looking for the default value of huge pages.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-07-29 11:25:16 +01:00
Peter Krempa
f8cf4962ac storage: create: Create files with correct mode
Use correct mode when pre-creating files (for snapshots). The refactor
changing to storage driver usage caused a regression as some systems
created the file with 000 permissions forbidding qemu to write the file.

Pass mode to the creating functions to avoid the problem.

Regression since 185e07a5f8.
2014-07-29 10:45:32 +02:00
Chen Hanxiao
71ee25f562 nodedev: fix a uninitialized variable build failure
Fix a -Werror=maybe-uninitialized warning

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-28 22:01:59 -06:00
Eric Blake
c6a4d268af nodedev: fix pci express memory leak
Leak introduced in commit 16ebf10f (v1.2.6), detected by valgrind:

==9816== 216 (96 direct, 120 indirect) bytes in 6 blocks are definitely lost in loss record 665 of 821
==9816==    at 0x4A081D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9816==    by 0x50836FB: virAlloc (viralloc.c:144)
==9816==    by 0x1DBDBE27: udevProcessPCI (node_device_udev.c:546)
==9816==    by 0x1DBDD79D: udevGetDeviceDetails (node_device_udev.c:1293)

* src/util/virpci.h (virPCIEDeviceInfoFree): New prototype.
* src/util/virpci.c (virPCIEDeviceInfoFree): New function.
* src/conf/node_device_conf.c (virNodeDevCapsDefFree): Clear
pci_express under pci case.
(virNodeDevCapPCIDevParseXML): Avoid leak.
* src/node_device/node_device_udev.c (udevProcessPCI): Likewise.
* src/libvirt_private.syms (virpci.h): Export it.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-28 14:10:29 -06:00
Eric Blake
be05c1414d nodedev: move pci express types to virpci.h
Finding virPCIE* code is more intuitive if located in virpci.h
instead of node_device_conf.h.

* src/conf/node_device_conf.h (virPCIELinkSpeed, virPCIELink)
(virPCIEDeviceInfo): Move...
* src/util/virpci.h: ...here.
* src/conf/node_device_conf.c (virPCIELinkSpeed): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-28 14:10:25 -06:00
Eric Blake
3261895a06 nodedev: let compiler help us on switches
The compiler can alert us to places where we need to expand switch
statements because we add a new enum value, but only if we don't
have a default case.

* src/conf/node_device_conf.c (virNodeDeviceDefFormat)
(virNodeDevCapsDefParseXML, virNodeDevCapsDefFree): Drop default
case.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-28 13:41:41 -06:00
Peter Krempa
a813d1c61b qemu: sound: Fix uninitialized model string
Commit e5f36698e3 introduces a
false-positive build failure in the sound card model handling switch.
Initialize the model to NULL although the value should never be used.
2014-07-28 11:38:35 +02:00
Peter Krempa
e5f36698e3 qemu: sound: Handle all possible sound cards in switch statement
Use correct type in the switch and handle all sound card models in it so
that the compiler tracks additions.
2014-07-28 10:46:33 +02:00
Peter Krempa
1c6999d340 conf: RNG: Always fill in default random source path for default backend
Libvirt documents that the default entropy source for the 'random'
backend of a RNG device is /dev/random. Instead of storing and
propagating NULL across our code and checking it in multiple places fill
the default in the post parse callback and use that in the other places.
2014-07-28 10:07:09 +02:00
Peter Krempa
efdb9117ee qemu: Fix starting of VMs with empty CDROM drives
Since 24e5cafba6 (thankfully unreleased)
when a VM with an empty disk drive would be started the code would call
stat() on NULL path as a check was missing from the callback rendering
machines unstartable.

Report success when the path is empty (denoting an empty drive).
2014-07-25 14:33:07 +02:00
James
febfe83721 util: virTimeFieldsThenRaw never returns negative
virTimeFieldsThenRaw will never return negative result, so I clean up
the related meaningless judgements to make it better.

Signed-off-by: James <james.wangyufei@huawei.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-07-25 12:06:07 +02:00
Li Yang
ccdf708245 libvirt: Fix 'quest' typo in comment
Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
2014-07-25 11:30:14 +02:00
Peter Krempa
bbddbefa2f virtio-rng: allow multiple RNG devices
qemu supports adding multiple RNG devices. This patch allows libvirt to
support this.
2014-07-25 09:34:53 +02:00
Peter Krempa
99ff49eed1 qemu: cgroup: Don't use NULL path on default backed RNGs
The "random" backend for virtio-rng can be started with no path
specified which equals to /dev/random. The cgroup code didn't consider
this and called few of the functions with NULL resulting into:

 $ virsh start rng-vm
 error: Failed to start domain rng-vm
 error: Path '(null)' is not accessible: Bad address

Problem introduced by commit c6320d3463
2014-07-25 09:34:53 +02:00
Michal Privoznik
3d968f409f qemuConnectGetDomainCapabilities: Report error on unknown arch
If user hasn't provided any @emulatorbin, the qemuCaps are
searched by @arch provided (which in fact can be guessed from the
host). However, there's no guarantee that the qemu binary for
@arch will exist.  Therefore qemu capabilities may be nonexistent
too. If that's the case, we should throw an error message prior
jumping onto 'cleanup' label as the helper lookup function
remains silent on no search result.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-07-24 18:01:57 +02:00
Martin Kletzander
9318121db8 remove range checking for blkiotune weight
This was changed before:

https://www.redhat.com/archives/libvir-list/2013-October/msg00525.html

but not everywhere in the code.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1100769

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-07-24 17:32:37 +02:00
Roman Bogorodskiy
d704e69858 bhyve: cdrom support
Add support for CDROM devices for bhyve driver using
bhyve(8)'s 'ahci-cd' device type.

As bhyve currently does not support media insertion at runtime,
disallow to start a domain with an empty source path for cdrom
devices.
2014-07-24 18:56:37 +04:00
John Ferlan
17bddc46f4 hostdev: Introduce virDomainHostdevSubsysSCSIiSCSI
Create the structures and API's to hold and manage the iSCSI host device.
This extends the 'scsi_host' definitions added in commit id '5c811dce'.
A future patch will add the XML parsing, but that code requires some
infrastructure to be in place first in order to handle the differences
between a 'scsi_host' and an 'iSCSI host' device.
2014-07-24 07:04:44 -04:00
John Ferlan
a062d1a1cc Add virConnectPtr for qemuBuildSCSIHostdevDrvStr
Add a conn for future patches to be able to grab the secret when
authenticating an iSCSI host device
2014-07-24 06:39:28 -04:00
John Ferlan
42957661dc hostdev: Introduce virDomainHostdevSubsysSCSIHost
Split virDomainHostdevSubsysSCSI further. In preparation for having
either SCSI or iSCSI data, create a union in virDomainHostdevSubsysSCSI
to contain just a virDomainHostdevSubsysSCSIHost to describe the
'scsi_host' host device
2014-07-24 06:39:28 -04:00
John Ferlan
5805621cd9 hostdev: Introduce virDomainHostdevSubsysSCSI
Create a separate typedef for the hostdev union data describing SCSI
Then adjust the code to use the new pointer
2014-07-24 06:39:27 -04:00
John Ferlan
1c8da0d44e hostdev: Introduce virDomainHostdevSubsysPCI
Create a separate typedef for the hostdev union data describing PCI.
Then adjust the code to use the new pointer
2014-07-24 06:39:27 -04:00
John Ferlan
7540d07f09 hostdev: Introduce virDomainHostdevSubsysUSB
Create a separate typedef for the hostdev union data describing USB.
Then adjust the code to use the new pointer
2014-07-24 06:39:27 -04:00
Peter Krempa
185e07a5f8 qemu: snapshot: Use storage driver to pre-create snapshot file
Move the last operation done on local files to the storage driver API.
2014-07-24 09:59:00 +02:00
Peter Krempa
a2a67eff18 storage: Implement virStorageFileCreate for local and gluster files
Add backends for this frontend function so that we can use it in the
snapshot creation code.
2014-07-24 09:59:00 +02:00
Peter Krempa
24e5cafba6 qemu: Implement DAC driver chown callback to co-operate with storage drv
Use the storage driver to chown remote images.
2014-07-24 09:59:00 +02:00
Peter Krempa
0a515a3ba3 security: DAC: Plumb usage of chown callback
Use the callback to set disk and storage image labels by modifying the
existing functions and adding wrappers to avoid refactoring a lot of the
code.
2014-07-24 09:59:00 +02:00
Peter Krempa
7490a6d272 security: DAC: Introduce callback to perform image chown
To integrate the security driver with the storage driver we need to
pass a callback for a function that will chown storage volumes.

Introduce and document the callback prototype.
2014-07-24 09:58:59 +02:00
Peter Krempa
9f28599d51 security: DAC: Remove superfluous link resolution
When restoring security labels in the dac driver the code would resolve
the file path and use the resolved one to be chown-ed. The setting code
doesn't do that. Remove the unnecessary code.
2014-07-24 09:58:59 +02:00
Peter Krempa
222860cd36 storage: Add witness for checking storage volume use in security driver
With my intended use of storage driver assist to chown files on remote
storage we will need a witness that will tell us whether the given
storage volume supports operations needed by the storage driver.
2014-07-24 09:58:59 +02:00
Peter Krempa
50f09651df storage: Implement storage driver helper to chown disk images
Gluster storage works on a similar principle to NFS where it takes the
uid and gid of the actual process and uses it to access the storage
volume on the remote server. This introduces a need to chown storage
files on gluster via native API.
2014-07-24 09:58:59 +02:00
Michal Privoznik
12926a7c39 qemuConnectGetDomainCapabilities: Use wiser defaults
Up to now, users have to pass two arguments at least: domain virt type
('qemu' vs 'kvm') and one of emulatorbin or architecture. This is not
much user friendly. Nowadays users mostly use KVM and share the host
architecture with the guest. So now, the API (and subsequently virsh
command) can be called with all NULLs  (without any arguments).

Before this patch:
 # virsh domcapabilities
 error: failed to get emulator capabilities
 error: virttype_str in qemuConnectGetDomainCapabilities must not be NULL

 # virsh domcapabilities kvm
 error: failed to get emulator capabilities
 error: invalid argument: at least one of emulatorbin or architecture fields must be present

After:

 # virsh domcapabilities
 <domainCapabilities>
   <path>/usr/bin/qemu-system-x86_64</path>
   <domain>kvm</domain>
   <machine>pc-i440fx-2.1</machine>
   <arch>x86_64</arch>
   <vcpu max='255'/>
 </domainCapabilities>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-07-24 09:19:09 +02:00
Martin Kletzander
dc8b7ce7bc numatune: finish the split from domain_conf and remove all dependencies
This patch adds back the virDomainDef typedef into domain_conf and
makes all the numatune_conf functions independent of any virDomainDef
definitions.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-07-24 08:40:25 +02:00
Nehal J Wani
6675a0ab65 leaseshelper: avoid mem leak after storing lease entries
Contents of existing lease file were being stored in a variable
which was never freed.
2014-07-23 19:27:39 -06:00
Eric Blake
55d54dd938 conf: avoid memory leaks while parsing seclabel
Our seclabel parsing was repeatedly assigning malloc'd data into a
temporary variable, without first freeing the previous use.  Among
other leaks flagged by valgrind:

==9312== 8 bytes in 1 blocks are definitely lost in loss record 88 of 821
==9312==    at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9312==    by 0x8C40369: strdup (strdup.c:42)
==9312==    by 0x50EA799: virStrdup (virstring.c:676)
==9312==    by 0x50FAEB9: virXPathString (virxml.c:90)
==9312==    by 0x50FAF1E: virXPathStringLimit (virxml.c:112)
==9312==    by 0x510F516: virSecurityLabelDefParseXML (domain_conf.c:4571)
==9312==    by 0x510FB20: virSecurityLabelDefsParseXML (domain_conf.c:4720)

While it was multiple problems, it looks like commit da78351 (thankfully
unreleased) was to blame for all of them.

* src/conf/domain_conf.c (virSecurityLabelDefParseXML): Plug leaks
detected by valgrind.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-23 13:52:57 -06:00
Eric Blake
ee70839bbf nwfilter: plug memory leak with firewall
Introduced in commit 70571ccc (v1.2.4). Caught by valgrind:

==9816== 170 (32 direct, 138 indirect) bytes in 1 blocks are definitely lost in loss record 646 of 821
==9816==    at 0x4A081D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9816==    by 0x50836FB: virAlloc (viralloc.c:144)
==9816==    by 0x50AEC2B: virFirewallNew (virfirewall.c:204)
==9816==    by 0x1E2308ED: ebiptablesDriverProbeStateMatch (nwfilter_ebiptables_driver.c:3715)
==9816==    by 0x1E2309AD: ebiptablesDriverInit (nwfilter_ebiptables_driver.c:3742)

* src/nwfilter/nwfilter_ebiptables_driver.c
(ebiptablesDriverProbeStateMatch): Properly clean up.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-23 13:15:14 -06:00
Eric Blake
60e4944059 metadata: track title edits across libvirtd restart
https://bugzilla.redhat.com/show_bug.cgi?id=1122205

Although the edits were changing in-memory XML, it was not flushed
to disk; so unless some other action changes XML, a libvirtd restart
would lose the changed information.

* src/conf/domain_conf.c (virDomainObjSetMetadata): Add parameter,
to save live status across restarts.
(virDomainSaveXML): Allow for test driver.
* src/conf/domain_conf.h (virDomainObjSetMetadata): Adjust
signature.
* src/bhyve/bhyve_driver.c (bhyveDomainSetMetadata): Adjust caller.
* src/lxc/lxc_driver.c (lxcDomainSetMetadata): Likewise.
* src/qemu/qemu_driver.c (qemuDomainSetMetadata): Likewise.
* src/test/test_driver.c (testDomainSetMetadata): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-23 10:07:34 -06:00
Cédric Bosdonnat
94157da601 Documented VIR_DOMAIN_FEATURE_CAPABILITIES use of virDomainCapabilitesPolicy 2014-07-23 16:21:59 +02:00
Ján Tomko
3227e17d82 Introduce virTristateSwitch enum
For the values "default", "on", "off"

Replaces
virDeviceAddressPCIMulti
virDomainFeatureState
virDomainIoEventFd
virDomainVirtioEventIdx
virDomainDiskCopyOnRead
virDomainMemDump
virDomainPCIRombarMode
virDomainGraphicsSpicePlaybackCompression
2014-07-23 12:59:40 +02:00
Ján Tomko
bb018ce6c8 Introduce virTristateBool enum type
Replace all three-state (default/yes/no) enums with it:
virDomainBIOSUseserial
virDomainBootMenu
virDomainPMState
virDomainGraphicsSpiceClipboardCopypaste
virDomainGraphicsSpiceAgentFileTransfer
virNetworkDNSForwardPlainNames
2014-07-23 12:37:39 +02:00
Peter Krempa
0e6cacc4b1 Fix build after 47e5b5ae32
The patch described above introduced two problems caught by the compiler
and thus breaking the build.

One of the problems was comparison of unsigned with < 0 and the second
one jumped a variable init.
2014-07-23 10:19:20 +02:00
Chen Hanxiao
1ce7c1d20c LXC: show used memory as 0 when domain is not active
Before:
virsh # dominfo chx3
State:          shut off
Max memory:     92160 KiB
Used memory:    92160 KiB

After:
virsh # dominfo container1
State:          shut off
Max memory:     92160 KiB
Used memory:    0 KiB

Similar to qemu cases.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
2014-07-23 15:12:52 +08:00
Cédric Bosdonnat
26d67015b8 lxc domain from xml: convert lxc.cap.drop 2014-07-23 15:12:37 +08:00
Cédric Bosdonnat
47e5b5ae32 lxc: allow to keep or drop capabilities
Added <capabilities> in the <features> section of LXC domains
configuration. This section can contain elements named after the
capabilities like:

  <mknod state="on"/>, keep CAP_MKNOD capability
  <sys_chroot state="off"/> drop CAP_SYS_CHROOT capability

Users can restrict or give more capabilities than the default using
this mechanism.
2014-07-23 15:12:37 +08:00