Commit Graph

43050 Commits

Author SHA1 Message Date
Peter Krempa
0a67ae731a virstoragetest: Rework TEST_LOOKUP* cases to work on fake backing chain
Rather than using 'qemu-img' and rewriting the chain we can use fake
data and few empty files to ensure the same level of coverage. This is
possible since we've already tested that the metadata parsing from files
works properly and the only thing we are testing here is that the
symlink resolution works properly.

Additionally after the refactor of 'virstoragetest' is complete
additional tests on real data will be added.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-09 15:29:00 +02:00
Peter Krempa
d361234549 virstoragetest: Remove redundant arguments for chain lookup tests
Passing in both "chain*" and "chain*->path" is pointless. Use only the
full struct which we can use to infer the rest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-09 15:29:00 +02:00
Peter Krempa
80c1fea639 virstoragetest: Store output of TEST_CHAIN in output files
The TEST_CHAIN cases were storing the expected output (or rather data
to generate the expected output) in code. This made the code really hard
to follow and even harder to modify to add new cases.

This patch modifies the code to store the expected output in text files
(using the same generator as we've used to) and uses
'virTestCompareToFile' to check the outputs.

The result is that the code is way simpler and doesn't require fiddling
with 'testFileData' structs when adding new cases. Additionally this
removes mixing of code and declaration so we can stop disabling the
warning for this file.

Another advantage is that the tests are now named so it's easier to
figure out if one of them breaks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-09 15:29:00 +02:00
Peter Krempa
de59c4bba2 testutils: Introduce helper for stripping bulilddir/srcdir from test outputs
In certain cases we want to be able to compare test output containing
real paths against a static output file and thus we need a helper which
strips srcdir/builddir from given path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-09 15:29:00 +02:00
Peter Krempa
aea559fa74 virstoragetest: Drop testing of NBD backends via parsing real images
We now have specific tests for the backing store parser and previous
tests cover the extraction of the backing store string so there's no
need for these particular tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-09 15:29:00 +02:00
Peter Krempa
97d7177a11 virstoragetest: Drop testing of RBD backends via parsing real images
We now have specific tests for the backing store parser and previous
tests cover the extraction of the backing store string so there's no
need for these particular tests.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2021-09-09 15:29:00 +02:00
dinglimin
6e89972541 virsh: Display vhostuser socket path in domblklist
The domblklist command is designed to show a brief information
about the blocks of a domain. One piece of information that is
shows is "Target "and "Source". Before the modification, the
Vhost disk of SPDK is displayed as "-". After the modification,
the socket associated with it can be displayed.

Signed-off-by: dinglimin <dinglimin@cmss.chinamobile.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-09 13:56:06 +02:00
Peter Krempa
5a3c35dc83 qemuxml2argvtest: Add test case for missing disk '<target>'
Cover the case of missing disk target to cover the case fixed by
previous commit.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-09 10:17:28 +02:00
Peter Krempa
0404d4fc38 virDomainDiskDefValidate: Move validation of disk target
The disk target is mandatory and used as a designator in error messages
of other validation steps, so we must validate it first.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-09 10:17:28 +02:00
Peter Krempa
cf6b34c683 conf: Don't call 'virDomainDiskDefAssignAddress' when disk->dst is NULL
The code rejecting a XML when the disk target is missing was moved to
the validation code which goes after post parse. One of the cases in the
disk post parse code didn't check whether 'disk->dst' is set which at
that point isn't guaranteed.

Fixes: 61fd7174c2
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2001627
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-09 10:17:28 +02:00
Peter Krempa
002de683c6 conf: validate: Run global device definition validation before callbacks
The validation infrastructure doesn't modify the definition and
additionally it makes sense to run the global code first as it's
validating certain corner cases.

The changed error messages from qemuxml2argvtest show that this is
indeed the proper ordering as all changed messages are actually better
describing the error.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-09 10:17:28 +02:00
Peter Krempa
7dee442677 conf: validate: Move qemu-specific LUN disk validation to global validation
LUN disks are supported only by VMX and QEMU drivers and the VMX
implementation is a subset of qemu's implementation, thus we can move
the qemu-specific validator to the global validation code providing that
we allow the format to be 'none' (qemu driver always sets 'raw' if it's
not set) and allow disk type 'volume' as a source (qemu always
translates the source, and VMX doesn't implement 'volume' at all).

Moving the code to the global validation allows us to stop calling it
from the qemu specific validation and also deduplicates the checks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-09 10:17:28 +02:00
Peter Krempa
5ccb39616f qemuDomainDefValidateDiskLunSource: Unbreak error messages
Simplify looking for the error messages.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-09 10:17:28 +02:00
Ján Tomko
fa8ce012a3 libxl: use g_auto in libxlDomainGetEmulatorType
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
d6cd7a478f libxl: use g_auto in libxlCapsNodeData
Also remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
3e4c5e20b8 libxl: refactor libxlCapsInitCPU
Use g_auto, g_steal_pointer and remove unnecessary labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
5f5d698053 libxl: capsInitCPU: fail if we can't initialize host features
Introduced by:
  commit 17322e5518
      libxl: describe host cpu features based on hwcaps
with the justification that libxl_hwcaps does not have a stable
format across all version.

Even though the code would return '0' in the case of such failure,
it frees the 'cpu' pointer, while keeping it in caps->host.
Based on that, assume it does not happen in current usage.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
6b08d4b37d libxl: remove enum libxlHwcapVersion
As well as the code probing for the version in libxlCapsInitHost.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
a8328f5222 libxl: capabilities: assume Xen version >= 4.7
Remove the code handling old Xen's hwcap words,
as well as the comment describing it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
3376179092 Revert "meson: avoid bogus warnings from clang and g_autoptr"
Commit 345996c620 disabled the
-Wunused-but-set-variable warning on CLang, beacuse it warned
on variables that were unread, but we relied on the side effects
of their destructors.

Reinstate the warning now that all the occurrences have been fixed.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
eec09bcae6 rpc: mark source returned by virEventGLibAddSocketWatch as unused
Two users of virEventGLibAddSocketWatch care about the GSource
it returns.

The other three free it by assigning it to an autofreed variable.

Mark them with G_GNUC_UNUSED to make this obvious to the reader
and the compiler.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
a082c46229 util: virIdentitySetCurrent: only unref the old identity on success
In the unlikely case that we were unable to set the new
identity, we would unref the old one even though it still
could be in the thread-local storage.

Fixes: c6825d8813
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
09b08e9a80 qemu: remove unused 'cfg' variables
Unused as of:
  commit effeee5c2f
      qemu: driver: Use 'qemuDomainSaveStatus' for saving status XML

This function extracts the config from the vm object, so the caller
no longer needs to do it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
8120df4e85 virnetsockettest: refactor checkProtocols
Reduce variable scope, use g_auto and remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-09-08 16:19:55 +02:00
Ján Tomko
0fc4a43d24 tests: reduce variable scope in testSELinuxCheckLabels
And use g_auto.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-09-08 15:31:01 +02:00
Ján Tomko
dfee211d91 tests: esxutils: reduce variable scope in testConvertWindows1252ToUTF8
Also use g_auto.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-09-08 15:31:01 +02:00
Ján Tomko
ac1a9a5e8b tests: esxutils: reduce variable scope in testEscapeDatastoreItem
Also use g_auto.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-09-08 15:31:01 +02:00
Ján Tomko
4b4b44d82c tests: esxutils: refactor testParseDatastorePath
Reduce variable scope to match their lifetime,
use g_auto and remove now pointless labels in favor
of direct returns.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-09-08 15:31:01 +02:00
Ján Tomko
ff6e806be5 secretxml2xmltest: refactor testCompareXMLToXMLFiles
Use g_auto where possible and remove the pointless label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-08 15:29:05 +02:00
Ján Tomko
709ef46b2d tests: bhyve: use bitwise shift when defining flags
Although I'm sure we all know the powers of two by heart now,
this is the prevalent style for flag defition.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-09-08 15:13:12 +02:00
Ján Tomko
3fcf498174 tests: bhyve: remove magic constants
Refer to flags by their identifier, not value.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2021-09-08 15:13:12 +02:00
Kristina Hanicova
8f8eeb3750 virsh: add support for '--validate' option in create nwfilter-binding
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-09-06 17:08:59 +02:00
Kristina Hanicova
39f835621a nwfilter_driver: allow VIR_NWFILTER_BINDING_CREATE_VALIDATE flag
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-09-06 17:08:59 +02:00
Kristina Hanicova
eabb73eba2 conf: virnwfilterbindingdef: add validation against schema in create
We need to validate the XML against schema if option '--validate'
was passed to the virsh command. This patch also includes
propagation of flags into the virNWFilterBindingDefParse().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-09-06 17:08:59 +02:00
Kristina Hanicova
e21448e830 api: add virNWFilterBindingCreateFlags
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-09-06 17:08:59 +02:00
Kristina Hanicova
6779fca41c virsh: add support for '--validate' option in create network port
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-09-06 17:08:59 +02:00
Kristina Hanicova
652147d0e1 bridge_driver: allow VIR_NETWORK_PORT_CREATE_VALIDATE flag
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-09-06 17:08:59 +02:00
Kristina Hanicova
c2652059d6 conf: virnetworkportdef: add validation against schema in network port create
We need to validate the XML against schema if option '--validate'
was passed to the virsh command. This patch also includes
propagation of flags into the virNetworkPortDefParse().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-09-06 17:08:59 +02:00
Kristina Hanicova
c499b09e91 api: add VIR_NETWORK_PORT_CREATE_VALIDATE flag
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2021-09-06 17:08:59 +02:00
Michal Privoznik
5599dc547e qemu_driver: Don't check for g_strdup_printf() retval
The g_strdup_printf() function can't fail really. There's no need
to check for its return value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-09-06 16:20:38 +02:00
Michal Privoznik
1c2b96c206 qemu_driver.c: Fix file mode
In the previous commit I accidentally changed the mode of
qemu_driver.c file. Restore the original mode.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-06 13:45:22 +02:00
Lei Yang
d34640b0c0 qemu: fix iothread residual when qemuProcessSetupIOThread failed
In process of iothread hotplug, qemuDomainHotplugAddIOThread() calls
qemuProcessSetupIOThread(). When qemuProcessSetupIOThread() returned
a failure, only the cgroup directory 'iothread' was cleaned up within
the function. Right after that qemuDomainHotplugAddIOThread() would
return failure directly without rolling back the livedef and iothread
process that created previously.

Further, when 'virsh schedinfo domain --live' requires schedinfo of
such machine, the interface will always return a failure print as
follows: 'Failed to create v1 controller cpu for group: No such file
or directory'. The reason is qemuGetIOThreadsBWLive() using member
vm->def->iothreadids[0]->iothread_id to findout the corresponding
cgroup dircetory. In case mentioned previously, iothreadids[0] was not
been cleaned up while whose cgroup directroy has already been removed.

This patch rolls back the livedef and iothread process after
qemuProcessSetupIOThread() returned a failure. Of course we are not
limited to this function, we also perform the same rolling back after
any exception proecss in qemuDomainHotplugAddIOThread().

Signed-off-by: Lei Yang <yanglei209@huawei.com>
Signed-off-by: Wang Xin <wangxinxin.wang@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-09-06 13:42:01 +02:00
Masayoshi Mizuma
131fddd429 qemuValidateDomainDeviceDefDiskTransient: Validate that qemu doesn't terminate early
Setup of a disk with <transient shareBacking='yes'/> option issues a
reset of qemu. In cases when QEMU didn't yet support the 'set-action'
QMP libvirt would in certain cases setup the commandline without
'-no-shutdown' which caused qemu to exit during startup. Forbid this
specific scenario.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-09-06 11:13:06 +02:00
Masayoshi Mizuma
a2e6039cca qemu: process: Split out logic for setting the 'allowReboot' internal flag
Split out the logic which was used to determine whether qemu should
allow the guest OS to reboot for QEMU versions which don't support the
'set-action' QMP command.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2021-09-06 11:13:06 +02:00
jason lee
b6ec01b821 Translated using Weblate (Korean)
Currently translated at 47.7% (4943 of 10353 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: jason lee <ppark5237@gmail.com>
Signed-off-by: jason lee <ppark5237@gmail.com>
2021-09-03 19:08:41 +02:00
simmon
75cd019db5 Translated using Weblate (Korean)
Currently translated at 47.7% (4943 of 10353 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
2021-09-03 19:08:41 +02:00
simmon
3dbaaab128 Translated using Weblate (Korean)
Currently translated at 47.3% (4900 of 10353 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Translated using Weblate (Korean)

Currently translated at 47.3% (4900 of 10353 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
2021-09-01 16:30:04 +02:00
jason lee
30044a6f08 Translated using Weblate (Korean)
Currently translated at 47.3% (4900 of 10353 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Translated using Weblate (Korean)

Currently translated at 47.3% (4897 of 10353 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: jason lee <ppark5237@gmail.com>
Signed-off-by: jason lee <ppark5237@gmail.com>
2021-09-01 16:30:04 +02:00
simmon
a3acf8832f Translated using Weblate (Korean)
Currently translated at 47.3% (4897 of 10353 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: simmon <simmon@nplob.com>
Signed-off-by: simmon <simmon@nplob.com>
2021-09-01 16:30:04 +02:00
jason lee
73e44670d6 Translated using Weblate (Korean)
Currently translated at 46.9% (4865 of 10353 strings)

Translation: libvirt/libvirt
Translate-URL: https://translate.fedoraproject.org/projects/libvirt/libvirt/ko/

Co-authored-by: jason lee <ppark5237@gmail.com>
Signed-off-by: jason lee <ppark5237@gmail.com>
2021-09-01 16:30:04 +02:00