Commit Graph

44 Commits

Author SHA1 Message Date
Michal Privoznik
36cc189a46 tests: Add test cases for previous commit
This commit is rather big. Firstly, the in memory config
representation is adjusted like if security_driver was set to "none".
The rest is then just adaptation to the new code that will generate
different seclabels.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-05 08:35:34 +02:00
Eric Blake
58156f39ce capabilities: use bool instead of int
While preparing to add a capability for active commit, I noticed
that the existing code was abusing int for boolean values.

* src/conf/capabilities.h (_virCapsGuestFeature, _virCapsHost)
(virCapabilitiesNew, virCapabilitiesAddGuestFeature): Improve
types.
* src/conf/capabilities.c (virCapabilitiesNew)
(virCapabilitiesAddGuestFeature): Adjust signature.
* src/bhyve/bhyve_capabilities.c (virBhyveCapsBuild): Update
clients.
* src/esx/esx_driver.c (esxCapsInit): Likewise.
* src/libxl/libxl_conf.c (libxlMakeCapabilities): Likewise.
* src/lxc/lxc_conf.c (virLXCDriverCapsInit): Likewise.
* src/openvz/openvz_conf.c (openvzCapsInit): Likewise.
* src/parallels/parallels_driver.c (parallelsBuildCapabilities):
Likewise.
* src/phyp/phyp_driver.c (phypCapsInit): Likewise.
* src/qemu/qemu_capabilities.c (virQEMUCapsInit)
(virQEMUCapsInitGuestFromBinary): Likewise.
* src/security/virt-aa-helper.c (get_definition): Likewise.
* src/test/test_driver.c (testBuildCapabilities): Likewise.
* src/uml/uml_conf.c (umlCapsInit): Likewise.
* src/vbox/vbox_tmpl.c (vboxCapsInit): Likewise.
* src/vmware/vmware_conf.c (vmwareCapsInit): Likewise.
* src/xen/xen_hypervisor.c (xenHypervisorBuildCapabilities):
Likewise.
* src/xenapi/xenapi_driver.c (getCapsObject): Likewise.
* tests/qemucaps2xmltest.c (testGetCaps): Likewise.
* tests/testutils.c (virTestGenericCapsInit): Likewise.
* tests/testutilslxc.c (testLXCCapsInit): Likewise.
* tests/testutilsqemu.c (testQemuCapsInit): Likewise.
* tests/testutilsxen.c (testXenCapsInit): Likewise.
* tests/vircaps2xmltest.c (buildVirCapabilities): Likewise.
* tests/vircapstest.c (buildNUMATopology): Likewise.
* tests/vmx2xmltest.c (testCapsInit): Likewise.
* tests/xml2vmxtest.c (testCapsInit): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-14 08:00:46 -06:00
Michal Privoznik
3ecb9e7631 tests: Move qemu caps XML parsing into shared unit
Later on, we the qemu capabilities XML parsing code may come handy so
instead of duplicating the code make the already existing one shared.
By the same time, make the function accept file name instead of XML
document stored already in memory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-07-03 12:22:37 +02:00
Olivia Yin
61b1c681e0 change machine name ppce500v2 to ppce500
ppce500v2 is not machine supported by official release of QEMU.
It should be replaced by ppce500.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2014-05-27 08:48:57 +02:00
Ján Tomko
2dcdb7f654 Indent top-level labels by one space in tests/ 2014-03-25 14:58:41 +01:00
Martin Kletzander
f19b3a5f0c Use K&R style for curly braces in tests/
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-03-20 17:06:38 +01:00
Osier Yang
10c9ceff6d util: Add one argument for several scsi utils
To support passing the path of the test data to the utils, one
more argument is added to virSCSIDeviceGetSgName,
virSCSIDeviceGetDevName, and virSCSIDeviceNew, and the related
code is changed accordingly.

Later tests for the scsi utils will be based on this patch.

Signed-off-by: Osier Yang <jyang@redhat.com>
2014-01-30 15:48:28 +08:00
Pranavkumar Sawargaonkar
27e32e0f3d AArch64: Porting of armv7l conditons to run qemu for aarch64.
AArch64 qemu has similar behavior as armv7l, like use of mmio etc.
This patch adds similar bypass checks what we have for armv7l to aarch64.
E.g. we are enabling mmio transport for Nicdev.
Making addDefaultUSB and addDefaultMemballoon to false etc.

V3:
- Adding missing domain rng schema for aarcg64 and test case in
  testutilsqemu.c which was causing test suite failure
  while running make check.

V2:
- Added testcase to qemuxml2argvtest as suggested
  during review comments of V1.

V1:
- Initial patch.

Signed-off-by: Anup Patel <anup.patel@linaro.org>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
2014-01-06 11:02:24 -05:00
Cole Robinson
7c9617641d qemu: Don't add default memballoon device on ARM
And add test cases for a basic working ARM guest.
2013-09-02 16:53:39 -04:00
Osier Yang
3a6204cbbd qemu: Add callback struct for qemuBuildCommandLine
Since 0d70656afd, it starts to access the sysfs files to build
the qemu command line (by virSCSIDeviceGetSgName, which is to find
out the scsi generic device name by adpater🚌target:unit), there
is no way to work around, qemu wants to see the scsi generic device
like "/dev/sg6" anyway.

And there might be other places which need to access sysfs files
when building qemu command line in future.

Instead of increasing the arguments of qemuBuildCommandLine, this
introduces a new callback for qemuBuildCommandLine, and thus tests
can register their own callbacks for sysfs test input files accessing.

* src/qemu/qemu_command.h: (New callback struct
                            qemuBuildCommandLineCallbacks;
                            extern buildCommandLineCallbacks)
* src/qemu/qemu_command.c: (wire up the callback struct)
* src/qemu/qemu_driver.c: (Use the new syntax of qemuBuildCommandLine)
* src/qemu/qemu_hotplug.c: Likewise
* src/qemu/qemu_process.c: Likewise
* tests/testutilsqemu.[ch]: (Helper testSCSIDeviceGetSgName;
                             callback struct testCallbacks;)
* tests/qemuxml2argvtest.c: (Use testCallbacks)
* src/tests/qemuxmlnstest.c: (Like above)
2013-05-20 20:14:19 +08:00
Michal Privoznik
e60b9783e1 Adapt to VIR_STRDUP and VIR_STRNDUP in tests/* 2013-05-10 11:54:29 +02:00
Peter Krempa
482e5f159c virCaps: get rid of defaultConsoleTargetType callback
This patch refactors various places to allow removing of the
defaultConsoleTargetType callback from the virCaps structure.

A new console character device target type is introduced -
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE - to mark that no type was
specified in the XML. This type is at the end converted to the standard
VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL. Other types that are
different from this default have to be processed separately in the
device post parse callback.
2013-04-04 22:42:39 +02:00
Olivia Yin
0b3509e245 qemu: add dtb option support
The "dtb" option sets the filename for the device tree.
If without this option support, "-dtb file" will be converted into
<qemu:commandline> in domain XML file.
For example, '-dtb /media/ram/test.dtb' will be converted into
  <qemu:commandline>
    <qemu:arg value='-dtb'/>
    <qemu:arg value='/media/ram/test.dtb'/>
  </qemu:commandline>

This is not very friendly.
This patchset add special <dtb> tag like <kernel> and <initrd>
which is easier for user to write domain XML file.
  <os>
    <type arch='ppc' machine='ppce500v2'>hvm</type>
    <kernel>/media/ram/uImage</kernel>
    <initrd>/media/ram/ramdisk</initrd>
    <dtb>/media/ram/test.dtb</dtb>
    <cmdline>root=/dev/ram rw console=ttyS0,115200</cmdline>
  </os>

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-03-19 15:48:58 -06:00
Viktor Mihajlovski
3eefaccd47 S390: Testcases for virtio-ccw machines
This adds and corrects testcases for virtio devices on s390
guests.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2013-03-13 18:21:50 -06:00
Peter Krempa
27cf98e2d1 virCaps: conf: start splitting out irrelevat data
The virCaps structure gathered a ton of irrelevant data over time that.
The original reason is that it was propagated to the XML parser
functions.

This patch aims to create a new data structure virDomainXMLConf that
will contain immutable data that are used by the XML parser. This will
allow two things we need:

1) Get rid of the stuff from virCaps

2) Allow us to add callbacks to check and add driver specific stuff
after domain XML is parsed.

This first attempt removes pointers to private data allocation functions
to this new structure and update all callers and function that require
them.
2013-03-13 09:27:14 +01:00
Daniel P. Berrange
fed92f08db Turn virCapabilities into a virObject
To enable virCapabilities instances to be reference counted,
turn it into a virObject. All cases of virCapabilitiesFree
turn into virObjectUnref

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-02-08 11:34:26 +00:00
Daniel P. Berrange
ab9b7ec2f6 Rename memory.{c,h} to viralloc.{c,h} 2012-12-21 11:17:14 +00:00
Daniel P. Berrange
392c192240 Fix test cases for virArch changes 2012-12-18 19:32:23 +00:00
Viktor Mihajlovski
b1c88c1476 capabilities: defaultConsoleTargetType can depend on architecture
For S390, the default console target type cannot be of type 'serial'.
It is necessary to at least interpret the 'arch' attribute
value of the os/type element to produce the correct default type.

Therefore we need to extend the signature of defaultConsoleTargetType
to account for architecture. As a consequence all the drivers
supporting this capability function must be updated.

Despite the amount of changed files, the only change in behavior is
that for S390 the default console target type will be 'virtio'.

N.B.: A more future-proof approach could be to to use hypervisor
specific capabilities to determine the best possible console type.
For instance one could add an opaque private data pointer to the
virCaps structure (in case of QEMU to hold capsCache) which could
then be passed to the defaultConsoleTargetType callback to determine
the console target type.
Seems to be however a bit overengineered for the use case...

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2012-11-09 09:20:59 -07:00
Viktor Mihajlovski
028ba4f375 S390: Adding testcases for s390
Add minimal s390-virtio domain testcase and testcases for virtio serial,
net, disk for the virtio-s390 bus.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2012-07-11 11:19:05 +02:00
Hendrik Schwartke
a3389319ba Added the attribute vendor_id to the cpu model
Introducing the attribute vendor_id to force the CPUID instruction
in a kvm guest to return the specified vendor.
2012-07-03 12:06:38 +02:00
Eric Blake
72505073bd tests: avoid compiler warnings
gcc 4.7 warns about uninitialized struct members

* tests/testutilsqemu.c (testQemuCapsInit): Populate new members.
* tests/viruritest.c (mymain): Likewise.
2012-04-05 22:07:41 -06:00
Jiri Denemark
f7dd3a4e62 Add support for cpu mode attribute
The mode can be either of "custom" (default), "host-model",
"host-passthrough". The semantics of each mode is described in the
following examples:

- guest CPU is a default model with specified topology:
    <cpu>
      <topology sockets='1' cores='2' threads='1'/>
    </cpu>

- guest CPU matches selected model:
    <cpu mode='custom' match='exact'>
      <model>core2duo</model>
    </cpu>

- guest CPU should be a copy of host CPU as advertised by capabilities
  XML (this is a short cut for manually copying host CPU specification
  from capabilities to domain XML):
    <cpu mode='host-model'/>

  In case a hypervisor does not support the exact host model, libvirt
  automatically falls back to a closest supported CPU model and
  removes/adds features to match host. This behavior can be disabled by
    <cpu mode='host-model'>
      <model fallback='forbid'/>
    </cpu>

- the same as previous returned by virDomainGetXMLDesc with
  VIR_DOMAIN_XML_UPDATE_CPU flag:
    <cpu mode='host-model' match='exact'>
      <model fallback='allow'>Penryn</model>       --+
      <vendor>Intel</vendor>                         |
      <topology sockets='2' cores='4' threads='1'/>  + copied from
      <feature policy='require' name='dca'/>         | capabilities XML
      <feature policy='require' name='xtpr'/>        |
      ...                                          --+
    </cpu>

- guest CPU should be exactly the same as host CPU even in the aspects
  libvirt doesn't model (such domain cannot be migrated unless both
  hosts contain exactly the same CPUs):
    <cpu mode='host-passthrough'/>

- the same as previous returned by virDomainGetXMLDesc with
  VIR_DOMAIN_XML_UPDATE_CPU flag:
    <cpu mode='host-passthrough' match='minimal'>
      <model>Penryn</model>                        --+ copied from caps
      <vendor>Intel</vendor>                         | XML but doesn't
      <topology sockets='2' cores='4' threads='1'/>  | describe all
      <feature policy='require' name='dca'/>         | aspects of the
      <feature policy='require' name='xtpr'/>        | actual guest CPU
      ...                                          --+
    </cpu>
2012-01-17 11:39:23 +01:00
Jiri Denemark
a6f88cbd2d cpu: Optionally forbid fallback CPU models
In case a hypervisor doesn't support the exact CPU model requested by a
domain XML, we automatically fallback to a closest CPU model the
hypervisor supports (and make sure we add/remove any additional features
if needed). This patch adds 'fallback' attribute to model element, which
can be used to disable this automatic fallback.
2012-01-17 11:39:19 +01:00
Michael Ellerman
bbae92f8b8 tests: Add fake PPC64 emulator for QEMU testing
Create a fake PPC64 QEMU so that we can run PPC64 QEMU tests when we
don't have a real version of the emulator available.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
2011-12-20 16:14:09 -07:00
Daniel P. Berrange
209c2880b9 Fix default console type setting
The default console type may vary based on the OS type. ie a Xen
paravirt guests wants a 'xen' console, while a fullvirt guests
wants a 'serial' console.

A plain integer default console type in the capabilities does
not suffice. Instead introduce a callback that is passed the
OS type.

* src/conf/capabilities.h: Use a callback for default console
  type
* src/conf/domain_conf.c, src/conf/domain_conf.h: Use callback
  for default console type. Add missing LXC/OpenVZ console types.
* src/esx/esx_driver.c, src/libxl/libxl_conf.c,
  src/lxc/lxc_conf.c, src/openvz/openvz_conf.c,
  src/phyp/phyp_driver.c, src/qemu/qemu_capabilities.c,
  src/uml/uml_conf.c, src/vbox/vbox_tmpl.c,
  src/vmware/vmware_conf.c, src/xen/xen_hypervisor.c,
  src/xenapi/xenapi_driver.c: Set default console type callback
2011-11-03 12:01:48 +00:00
Jiri Denemark
aa3b2e40f5 tests: Fake host capabilities properly
Since we fake host CPU we should also fake host arch instead of taking
the real architecture tests are running on.
2011-02-15 22:51:37 +01:00
Daniel P. Berrange
1d16f05674 Update QEMU test cases for new file locations & API renames
* qemuargv2xmltest.c, qemuhelptest.c,
  qemuxml2argvtest.c, testutilsqemu.c: Update includes and
  cope with API renames
2010-12-17 16:41:51 +00:00
Eric Blake
aca20efbf8 capabilities, cpu: use new array API
* src/conf/capabilities.h (_virCaps, _virCapsHost, _virCapsGuest)
(_virCapsGuestArch): Add additional fields.
* src/conf/cpu_conf.h (_virCPUDef): Likewise.
* src/conf/capabilities.c (virCapabilitiesFormatXML): Reflect
updated type.
(virCapabilitiesAddGuest, virCapabilitiesAddHostFeature)
(virCapabilitiesAddHostMigrateTransport)
(virCapabilitiesAddHostNUMACell, virCapabilitiesAddGuestFeature)
(virCapabilitiesAddGuestDomain): Use new array APIs.
* src/conf/cpu_conf.c (virCPUDefAddFeature, virCPUDefCopy)
(virCPUDefParseXML): Likewise.
* tests/testutilsqemu.c (testQemuCapsInit): Adjust test.
2010-11-18 12:21:58 -07:00
Chris Lalancette
a71be01f04 Add tests for the new Qemu namespace XML.
Thanks to DV for knocking together the Relax-NG changes
quickly for me.

Changes since v1:
 - Change the domain.rng to correspond to the new schema
 - Don't allocate caps->ns in testQemuCapsInit since it is a static table

Changes since v2:
 - Change domain.rng to add restrictions on allowed environment names

Changes since v3:
 - Remove a bogus comment in the tests

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:45 -04:00
Jiri Denemark
af53714f47 cpu: Add support for CPU vendor
By specifying <vendor> element in CPU requirements a guest can be
restricted to run only on CPUs by a given vendor. Host CPU vendor is
also specified in capabilities XML.

The vendor is checked when migrating a guest but it's not forced, i.e.,
guests configured without <vendor> element can be freely migrated.
2010-07-07 17:26:00 +02:00
Eric Blake
2788f4d1d4 testutilsqemu: avoid uninitialized variable
* tests/testutilsqemu.c (testQemuCapsInit): Initialize variables.
2010-04-22 09:00:30 -06:00
Jiri Denemark
b34e082079 Fake host CPU for qemu tests 2010-04-22 10:21:05 +02:00
Eric Blake
36d8e7d8d7 build: consistently indent preprocessor directives
* global: patch created by running:
for f in $(git ls-files '*.[ch]') ; do
    cppi $f > $f.t && mv $f.t $f
done
2010-03-09 19:22:28 +01:00
Daniel P. Berrange
e8ac4a79f1 Make test suite output less verbose
Only print out '.' for each test case, full test output can be
re-enabled with VIR_TEST_VERBOSE=1, or VIR_TEST_DEBUG=XXXX

Sample output now looks like

  TEST: statstest
        ........................................ 40
        ...................................      75  OK
  PASS: statstest
  TEST: qparamtest
        ................................         32  OK
  PASS: qparamtest
  TEST:
        ............                             12  OK
2010-01-15 16:28:05 +00:00
Cole Robinson
9710856b33 tests: Centralize VIR_TEST_DEBUG lookup, and document it
Provide a simple interface for other tests to lookup the testDebug variable.
Also remove a redundant error message in interface tests.

If anyone feels inclined to change this env variable to match the existing
LIBVIRT_* format, it should now be easier to do so.
2009-10-20 14:17:34 -04:00
Mark McLoughlin
e52d608ddf Test that domain-specific qemu machine types are used correctly
* tests/testutilsqemu.c: add a machine types list for /usr/bin/kvm
  which doesn't have any aliases, while the guest has aliases

* tests/qemuxml2argvdata/qemuxml2argv-machine-aliases2.*,
  tests/qemuxml2argvtest.c: add a test using /usr/bin/kvm and make
  sure that 'pc' machine type doesn't get canonicalized using the
  aliases in the guest machine type list
2009-09-10 12:37:43 +01:00
Mark McLoughlin
aa67241bde Test qemu machine aliases
* tests/testutilsqemu.c: make 'pc' an alias for qemu-system-x86_64

* tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.*,
  tests/qemuxml2argvtest.c: add a test which uses qemu-system-x86_64
  and make sure the machine type is canonicalized.
2009-09-10 12:37:42 +01:00
Mark McLoughlin
d4c032d0b7 Re-factor qemu test machine allocation code
* test/testutilsqemu.c: split out code to testQemuAllocMachines()
  and make use of the ARRAY_CARDINALITY macro
2009-09-10 12:37:42 +01:00
Mark McLoughlin
d7ed2c18e1 Dump qemu driver capabilities if test debugging enabled
* src/testutils.[ch]: make testDebug externally available

* src/testutilsqemu.c: if VIR_TEST_DEBUG is set, dump the qemu
  driver capabilities to stderr
2009-09-10 12:37:42 +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
Atsushi SAKAI
fbb5d771a0 Compilation fixes for MinGW 2008-06-26 09:37:51 +00:00
Daniel P. Berrange
7852a63443 Added missing config.h import 2008-05-22 16:18:40 +00:00
Daniel P. Berrange
40a82f3066 Make QEMU test suite independant of host OS capabilities 2008-05-16 16:51:30 +00:00