Commit Graph

56 Commits

Author SHA1 Message Date
Dario Faggioli
e6c29f09e5 conf: Add support for specifying CPU max physical address size
This patch introduces the

    <maxphysaddr mode='passthrough'/>
    <maxphysaddr mode='emulate' bits='42'/>

sub element of /domain/cpu, which allows specifying the guest virtual CPU
address size. This can be useful if the guest needs to have a large amount
of memory.

If mode='passthrough', the virtual CPU will have the same number of address
bits as the host. If mode='emulate', the mandatory bits attribute specifies
the number of address bits.

Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2022-08-04 09:04:07 +02:00
Peng Liang
48e8c36b05 tests: Remove unused includes
Signed-off-by: Peng Liang <tcx4c70@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2022-06-16 06:43:58 +02:00
Martin Kletzander
97ef63860a tests: Add test for missing network attribute in graphics' listen element
This tests a change done in commit 871a071abb.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2022-05-04 16:11:43 +02:00
Peter Krempa
1e4aff444c virDomainBackupDefFormat: Propagate private data callbacks
The formatter for the backup job data didn't pass the virDomainXMLOption
struct to the disk formatter which meant that the private data of the
disk source were not formatted.

This didn't pose a problem for now as the blockjob list remembered the
nodenames for the jobs, but the backup source lost them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-11-04 10:55:28 +01:00
Ján Tomko
296f7173ed tests: use g_autofree
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
2021-09-09 18:06:13 +02:00
Pavel Hrdina
38b5f4faab conf: introduce support for Fibre Channel VMID
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-08-17 13:50:38 +02:00
Michal Privoznik
5c254bb541 conf: Store SCSI bus length in virDomainDef
Libvirt assumes that a SCSI bus can fit up to 8 devices
(including controller itself), except for so called wide bus
which can accommodate up to 16 devices (again, including
controller). This plays important role when computing 'drive'
address in virDomainDiskDefAssignAddress(). So far, the only
driver that enables wide SCSI bus is VMX. But with newer
releases, ESX is capable of "super wide" bus (64 devices).

We can blindly bump the limit in our code because then we would
compute address that's invalid for older ESX versions that we
still want to support.

Unfortunately, I haven't found a better place where to store this
than virDomainDef.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-08-16 14:22:38 +02:00
Kristina Hanicova
bcad39457d genericxml2xmltest: Refactor DO_TEST_FULL() calls
I have added 2 new macros to call tests which are expected to
fail in order to make the code more consistent and readable.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-21 14:40:50 +02:00
Kristina Hanicova
0f4a65874a genericxml2xmltest: Substitute 'inactive' variable with 'active'
Having negation in a name of a bool variable seems a bit
confusing to me. I think the substitution makes the code much
more readable.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-21 14:40:46 +02:00
Boris Fiuczynski
9568a4d410 conf: Add s390-pv as launch security type
Add launch security type 's390-pv' as well as some tests.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-07-21 13:30:25 +02:00
Kristina Hanicova
b0b5820efe genericxml2xmltest: Modify cachetune test to include id
I changed DO_TEST_DIFFERENT to DO_TEST, which allows us to remove
the duplicate out file. I also added id attribute for domain
element in order to parse it as a live XML ('cachetune id' is in
the output of only live XMLs). Lastly I added id of cachetune to
test its output value.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-07-20 16:43:46 +02:00
Michal Privoznik
c8238579fb lib: Drop internal virXXXPtr typedefs
Historically, we declared pointer type to our types:

  typedef struct _virXXX virXXX;
  typedef virXXX *virXXXPtr;

But usefulness of such declaration is questionable, at best.
Unfortunately, we can't drop every such declaration - we have to
carry some over, because they are part of public API (e.g.
virDomainPtr). But for internal types - we can do drop them and
use what every other C project uses 'virXXX *'.

This change was generated by a very ugly shell script that
generated sed script which was then called over each file in the
repository. For the shell script refer to the cover letter:

https://listman.redhat.com/archives/libvir-list/2021-March/msg00537.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-04-13 17:00:38 +02:00
Matt Coleman
ce8fb26a66 schema: add support for Windows file paths and device names
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Matt Coleman <matt@datto.com>
2020-11-24 18:45:07 +00:00
Cole Robinson
14f877e8d0 tests: cover disk, interface <backenddomain>
There is present no XML test coverage for this.
Add genericxml parse + formatting coverage.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-10-05 12:43:00 -04:00
Bastien Orivel
d3aa28925f Add a check attribute on the mac address element
This is only used in the ESX driver where, when set to "no", it will
ignore all the checks libvirt does about the origin of the MAC address
(whether or not it's in a VMWare OUI) and forward the original one to
the ESX server telling it not to check it either.

This allows keeping a deterministic MAC address which can be useful for
licensed software which might dislike changes.

Signed-off-by: Bastien Orivel <bastien.orivel@diateam.net>

VMX conversion parts rewritten to apply on top of previously merged
support for type='generated|static'

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2020-07-23 16:11:39 +01:00
Peter Krempa
6f33e441e2 backupxml2xmltest: Call 'virDomainBackupAlignDisks' before formatting output
Call the post-processing function so that we can validate that it does
the correct thing.

virDomainBackupAlignDisks requires disk definitions to be present so
let's fake them by copying disks from the backup definition and add one
extra disk 'vdextradisk'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-08 08:40:30 +02:00
Peter Krempa
fffc147ba2 conf: backup: Store 'tlsAlias' and 'tlsSecretAlias' as internals of a backup
Add fields for storing the aliases necessary to clean up the TLS env for
a backup job after it finishes.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-07 12:58:19 +02:00
Peter Krempa
bfd9721671 testCompareBackupXML: Add infrastructure for testing internal fields
There are few internal fields of the backup XML. Propagate the
'internal' flag so that the test can verify the XML infrastructure.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2020-07-07 12:58:19 +02:00
Peter Krempa
a7db0b757d backup: Allow 'encryption' of backups and scratch images
Add the appropriate entries into the schema to allow encryption of the
backup or scratch image. Since we use blockdev internals for everything
no changes to the code are actually necessary.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2020-04-14 18:49:41 +02:00
Huaqiang
40a070ae01 conf: create memory bandwidth monitor.
Following domain configuration changes create two memory bandwidth
monitors: one is monitoring the bandwidth consumed by vCPU 0,
another is for vCPU 5.

```
               <cputune>
                 <memorytune vcpus='0-4'>
                   <node id='0' bandwidth='20'/>
                   <node id='1' bandwidth='30'/>
       +           <monitor vcpus='0'/>
                 </memorytune>
       +         <memorytune vcpus='5'>
       +           <monitor vcpus='5'/>
       +         </memorytune>

               </cputune>
    ```

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Huaqiang <huaqiang.wang@intel.com>
2019-12-13 15:55:43 +00:00
Huaqiang
1d0c3c3a62 cachetune schema: a looser check for the order of <cache> and <monitor> element
Originally, inside <cputune/cachetune>, it requires the <cache> element to
be in the position before <monitor>, and following configuration is not
permitted by schema, but it is better to let it be valid.

  <cputune>
    <cachetune vcpus='0-1'>
      <monitor level='3' vcpus='0-1'/>
            ^
            |__ Not permitted originally because it is in the place
                before <cache> element.

      <cache id='0' level='3' type='both' size='3' unit='MiB'/>
      <cache id='1' level='3' type='both' size='3' unit='MiB'/>
    </cachetune>
    ...
  </cputune>

And, let schema do more strict check by identifying following configuration to
be invalid, due to <cachetune> should contain at least one <cache> or <monitor>
element.

  <cputune>
    <cachetune vcpus='0-1'>
        ^
        |__ a <cachetune> SHOULD contain at least one <cache> or <monitor>

    </cachetune>
    ...
  </cputune>

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Huaqiang <huaqiang.wang@intel.com>
2019-12-13 15:31:26 +00:00
Peter Krempa
d0805c27f5 tests: genericxml2xml: Add testing of backup XML files
Now that the parser and formatter are in place we can exercise it on
the test files.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-12-10 12:41:56 +01:00
Michal Privoznik
4fa804c0c7 tests: Use g_strdup_printf() instead of virAsprintf()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-11-12 16:15:59 +01:00
Martin Kletzander
842bc56ad2 conf: Add support for emulatorsched
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-04-16 13:46:17 +02:00
Wang Huaqiang
a5c4e705a5 conf: Introduce cache monitor element in cachetune
Introducing <monitor> element under <cachetune> to represent
a cache monitor.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-11-14 12:18:46 -05:00
Erik Skultety
5165ff0971 src: More cleanup of some system headers already contained in internal.h
All of the ones being removed are pulled in by internal.h. The only
exception is sanlock which expects the application to include <stdint.h>
before sanlock's headers, because sanlock prototypes use fixed width
int, but they don't include stdint.h themselves, so we have to leave
that one in place.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-20 10:16:39 +02:00
Erik Skultety
9403b63102 internal: Move <stdio.h> include to internal.h
It doesn't really make sense for us to have stdlib.h and string.h but
not stdio.h in the internal.h header.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-20 10:16:38 +02:00
Bing Niu
6956b7eedc conf: Add support for memorytune XML processing for resctrl MBA
Introduce a new section memorytune to support memory bandwidth allocation.
This is consistent with existing cachetune. As the example:
below:
  <cputune>
    ......
    <memorytune vcpus='0'>
      <node id='0' bandwidth='30'/>
    </memorytune>
  </cputune>

vpus      --- vpus subjected to this memory bandwidth.
id        --- on which node memory bandwidth to be set.
bandwidth --- the memory bandwidth percent to set.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-08-13 14:19:41 -04:00
Brijesh Singh
e5791a0306 conf: Introduce launch-security element in domain
The launch-security element can be used to define the security
model to use when launching a domain. Currently we support 'sev'.

When 'sev' is used, the VM will be launched with AMD SEV feature enabled.
SEV feature supports running encrypted VM under the control of KVM.
Encrypted VMs have their pages (code and data) secured such that only the
guest itself has access to the unencrypted version. Each encrypted VM is
associated with a unique encryption key; if its data is accessed to a
different entity using a different key the encrypted guests data will be
incorrectly decrypted, leading to unintelligible data.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-06-12 10:00:49 +02:00
Martin Kletzander
1bd5a08d38 conf, schema, docs: Add support for TSEG size setting
TSEG (Top of Memory Segment) is one of many regions that SMM (System Management
Mode) can occupy.  This one, however is special, because a) most of the SMM code
lives in TSEG nowadays and b) QEMU just (well, some time ago) added support for
so called 'extended' TSEG.  The difference to the TSEG implemented in real q35's
MCH (Memory Controller Hub) is that it can offer one extra size to the guest OS
apart from the standard TSEG's 1, 2, and 8 MiB and that size can be selected in
1 MiB increments.  Maximum may vary based on QEMU and is way too big, so we
don't need to check for the maximum here.  Similarly to the memory size we'll
leave it to the hypervisor to try satisfying that and giving us an error message
in case it is not possible.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-06-08 10:28:46 +02:00
Peter Krempa
1b28038300 tests: util: Remove callback from testCompareDomXML2XMLFiles
The testCompareDomXML2XMLPreFormatCallback is no longer used and thus
can be removed.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-13 13:54:11 +01:00
Martin Kletzander
958e0431a9 tests: Add test for properly removing cachetune entries
Cachetune for unavailable vCPUs should be cleared the same way vcpupin and other
things do, so let's add tests for it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-02-02 14:51:32 +01:00
Martin Kletzander
7387e3fea4 conf: Add support for cputune/cachetune
More info in the documentation, this is basically the XML parsing/formatting
support, schemas, tests and documentation for the new cputune/cachetune element
that will get used by following patches.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-01-25 17:16:08 +01:00
Michal Privoznik
ab7a2fe230 test: Drop useless prefix for genericxml2xml test data
There's no reason for the files to have generic- prefix
since they all live under genericxml2xmlindata and
genericxml2xmloutdata directories.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-12-05 14:52:49 +01:00
Andrea Bolognani
3e7db8d3e8 Remove backslash alignment attempts
Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-11-03 13:24:12 +01:00
Pavel Hrdina
95fd63b170 tests: add generic xml chardev source reconnect tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-29 10:30:05 +02:00
Pavel Hrdina
21bfd1e9b9 conf: error out for multiple source elements while parsing chardev
Currently we accept and correctly parse this chardev XML:

  ...
  <channel type='tcp'>
    <source mode='connect'/>
    <source mode='bind' host='localhost'/>
    <source service='4567'/>
    <target type='virtio' name='test'/>
  </channel>
  ...

The parsed formatted XML is:

  ...
  <channel type='tcp'>
    <source mode='connect' host='localhost' service='4567'/>
    <target type='virtio' name='test'/>
  </channel>
  ...

That behavior is super wrong and should not be allowed.  If you notice
the current parse takes the first found attribute and uses that value,
so for example from the "<source mode='bind' host='localhost'/>" only
the "host" attribute is used.  It works the same way for all possible
attributes that we are able to parse for source element.

This patch enforces providing only one source element for all character
devices, only for UDP type we allow to provide two source elements
since you can specify both modes.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:28:40 +02:00
Pavel Hrdina
e90ba2541d tests: introduce genericxml test for UNIX chardev
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:28:40 +02:00
Pavel Hrdina
ad5982dd16 tests: introduce genericxml test for UDP chardev
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:28:40 +02:00
Pavel Hrdina
fedf120925 tests: introduce genericxml test for TCP chardev
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-08-22 17:28:40 +02:00
Peter Krempa
ef0bb841c9 tests: genericxml2xml: Add test case for HTTP based disk 2017-04-28 10:22:40 +02:00
Jiri Denemark
a646a6016a Add support for CPU cache specification
This patch introduces

    <cache level='N' mode='emulate'/>
    <cache mode='passthrough'/>
    <cache mode='disable'/>

sub element of /domain/cpu. Currently only a single <cache> element is
allowed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-27 22:07:14 +02:00
Andrea Bolognani
4ceac4bf29 tests: Rename VIRT_TEST_* macros to VIR_TEST_*
We use the "vir" prefix pretty consistently in our
APIs, both external and internal, which made these
macros stood out.
2017-04-04 17:30:03 +02:00
Pavel Hrdina
f19390d2d3 domain_conf: vnc: preserve autoport value if no port was specified
The issue is that if this graphics definition is provided:

  <graphics type='vnc' port='0'/>

it's parsed as:

  <graphics type='vnc' autoport='no'>
    <listen type='address'/>
  </graphics>

but if the resulting XML is parsed again the output is:

  <graphics type='vnc' port='-1' autoport='yes'>
    <listen type='address'/>
  </graphics>

and this should not happen.  The XML have to always remain the same
after it was already parsed by libvirt.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-01-27 09:46:03 +01:00
Peter Krempa
5847bc5c64 conf: Add XML for individual vCPU hotplug
Individual vCPU hotplug requires us to track the state of any vCPU. To
allow this add the following XML:

<domain>
  ...
  <vcpu current='2'>3</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='1' enabled='no' hotpluggable='yes'/>
  </vcpus>
  ...

The 'enabled' attribute allows to control the state of the vcpu.
'hotpluggable' controls whether given vcpu can be hotplugged and 'order'
allows to specify the order to add the vcpus.
2016-08-24 15:44:47 -04:00
Peter Krempa
dabf1c5b12 tests: genericxml2xml: Fix test file name
Commit b1fc6a7b added a test file but used a different name in the
actual test.
2016-06-23 21:11:32 +02:00
Peter Krempa
23690e1d74 conf: Fix perf event parser
The parser was totaly broken. Fix it by rewriting it. Add tests so that
it doesn't happen.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1346723
2016-06-17 09:35:14 +02:00
Pavel Hrdina
acc83afe33 vnc: add support for listen type 'socket'
VNC graphics already supports sockets but only via 'socket' attribute.
This patch coverts that attribute into listen type 'socket'.

For backward compatibility we need to handle listen type 'socket' and 'socket'
attribute properly to support old XMLs and new XMLs.  If both are provided they
have to match, if only one of them is provided we need to be able to parse that
configuration too.

To not break migration back to old libvirt if the socket is provided by user we
need to generate migratable XML without the listen element and use only 'socket'
attribute.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-06-09 14:42:48 +02:00
Tomáš Ryšavý
cd7dd1508d tests: Rename virtTestRun to virTestRun.
This function doesn't follow our convention of naming functions.
2016-06-08 11:23:12 -04:00
Pavel Hrdina
99c17cb205 genericxml2xml: add several graphics tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-05-06 15:53:16 +02:00