[libvirt] [PATCH tck] Change 'Sys::Virt::TCK::generic_domain' to take named params
by Daniel P. Berrange
To make it easier to add more optional parameters to the
Sys::Virt::TCK::generic_domain method, change it to take
named parameters instead of positional parameters.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
docs/writing-tests.pod | 6 ++---
lib/Sys/Virt/TCK.pm | 37 +++++++++++++++-----------
lib/Sys/Virt/TCK/NetworkHelpers.pm | 2 +-
scripts/domain/050-transient-lifecycle.t | 2 +-
scripts/domain/051-transient-autostart.t | 2 +-
scripts/domain/060-persistent-lifecycle.t | 2 +-
scripts/domain/061-persistent-autostart.t | 2 +-
scripts/domain/065-persistent-redefine.t | 2 +-
scripts/domain/070-transient-to-persistent.t | 2 +-
scripts/domain/080-unique-id-define.t | 8 +++---
scripts/domain/081-unique-id-create.t | 8 +++---
scripts/domain/082-unique-id-caching.t | 4 +--
scripts/domain/090-invalid-ops-when-inactive.t | 2 +-
scripts/domain/100-transient-save-restore.t | 2 +-
scripts/domain/101-persistent-save-restore.t | 2 +-
scripts/domain/102-broken-save-restore.t | 2 +-
scripts/domain/103-blockdev-save-restore.t | 2 +-
scripts/domain/120-disks-stats.t | 2 +-
scripts/domain/121-block-info.t | 2 +-
scripts/domain/130-cpu-hotplug.t | 2 +-
scripts/domain/180-interface-parameters.t | 2 +-
scripts/domain/200-disk-hotplug.t | 2 +-
scripts/domain/202-numa-set-parameters.t | 2 +-
scripts/domain/205-disk-hotplug-ordering.t | 2 +-
scripts/domain/207-disk-media-change.t | 2 +-
scripts/domain/210-nic-hotplug.t | 2 +-
scripts/domain/215-nic-hotplug-many.t | 2 +-
scripts/domain/240-usb-host-hotplug.t | 2 +-
scripts/domain/250-pci-host-hotplug.t | 2 +-
scripts/domain/300-migration.t | 2 +-
scripts/domain/301-migration-max-speed.t | 2 +-
scripts/hooks/052-domain-hook.t | 2 +-
scripts/qemu/100-disk-encryption.t | 2 +-
scripts/qemu/200-qcow2-single-backing-file.t | 2 +-
scripts/qemu/205-qcow2-double-backing-file.t | 2 +-
scripts/qemu/210-qcow2-auto-probing.t | 2 +-
scripts/qemu/400-save-image-xml.t | 2 +-
scripts/selinux/050-dynamic-relabel-yes.t | 2 +-
scripts/selinux/055-dynamic-base-label.t | 2 +-
scripts/selinux/100-static-relabel-no.t | 2 +-
scripts/selinux/105-static-relabel-fail.t | 2 +-
scripts/selinux/110-static-relabel-yes.t | 2 +-
42 files changed, 71 insertions(+), 66 deletions(-)
diff --git a/docs/writing-tests.pod b/docs/writing-tests.pod
index 3bc70b0..171166c 100644
--- a/docs/writing-tests.pod
+++ b/docs/writing-tests.pod
@@ -159,7 +159,7 @@ the exact config, just wanting a minimal generic domain config that is
highly likely to work without error. For such cases, a nice simple
API is provided:
- my $xml = $tck->generic_domain("test")->as_xml;
+ my $xml = $tck->generic_domain(name => "test")->as_xml;
This creates an XML document for a guest that is of the correct OS and
domain type to be able to run on the current hypervisor, with a name
@@ -167,7 +167,7 @@ of 'test', and a single disk. It is possible to set further parameters
if required. For example, to set an explicit UUID, give 3 virtual CPUs
and turn on ACPI:
- my $xml = $tck->generic_domain("test")->vcpus(3)
+ my $xml = $tck->generic_domain(name => "test")->vcpus(3)
->uuid("11111111-1111-2222-3333-444444444444")
->with_acpi()->as_xml()
@@ -357,7 +357,7 @@ Taking this into account, the complete example script looks like
END { $tck->cleanup if $tck; }
- my $xml = $tck->generic_domain("test")->as_xml;
+ my $xml = $tck->generic_domain(name => "test")->as_xml;
my $dom;
diag "Defining inactive domain config again";
diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
index a3a2732..57eb08c 100644
--- a/lib/Sys/Virt/TCK.pm
+++ b/lib/Sys/Virt/TCK.pm
@@ -607,14 +607,14 @@ sub get_kernel {
sub generic_machine_domain {
my $self = shift;
- my $name = shift;
- my $caps = shift;
- my $ostype = shift;
- my $conn = @_ ? shift : $self->conn;
+ my %params = @_;
+ my $name = exists $params{name} ? $params{name} : "tck";
+ my $ostype = exists $params{ostype} ? $params{ostype} : "hvm";
+ my $caps = exists $params{caps} ? $params{caps} : die "caps parameter is required";
my %config = $self->get_kernel($caps, $ostype);
- my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $conn,
+ my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $self->conn,
name => $name,
domain => $config{domain},
ostype => $config{ostype});
@@ -652,14 +652,14 @@ sub best_container_domain {
sub generic_container_domain {
my $self = shift;
- my $name = shift;
- my $caps = shift;
- my $domain = shift;
- my $conn = @_ ? shift : $self->conn;
+ my %params = @_;
+ my $name = exists $params{name} ? $params{name} : "tck";
+ my $caps = exists $params{caps} ? $params{caps} : die "caps parameter is required";
+ my $domain = exists $params{domain} ? $params{domain} : die "domain parameter is required";
my $bucket = "os-exe";
- my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $conn,
+ my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $self->conn,
name => $name,
domain => $domain,
ostype => "exe");
@@ -679,11 +679,12 @@ sub generic_container_domain {
sub generic_domain {
my $self = shift;
- my $name = @_ ? shift : "tck";
- my $ostype = @_ ? shift : undef;
- my $conn = shift || $self->conn;
+ my %params = @_;
+
+ my $name = exists $params{name} ? $params{name} : "tck";
+ my $ostype = exists $params{ostype} ? $params{ostype} : "hvm";
- my $caps = Sys::Virt::TCK::Capabilities->new(xml => $conn->get_capabilities);
+ my $caps = Sys::Virt::TCK::Capabilities->new(xml => $self->conn->get_capabilities);
my $container;
@@ -691,9 +692,13 @@ sub generic_domain {
unless $ostype && $ostype ne "exe";
if ($container) {
- return $self->generic_container_domain($name, $caps, $container);
+ return $self->generic_container_domain(name => $name,
+ caps => $caps,
+ domain => $container);
} else {
- return $self->generic_machine_domain($name, $caps, $ostype);
+ return $self->generic_machine_domain(name => $name,
+ caps => $caps,
+ ostype => $ostype);
}
}
diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm b/lib/Sys/Virt/TCK/NetworkHelpers.pm
index 5e1bac1..a2a8251 100644
--- a/lib/Sys/Virt/TCK/NetworkHelpers.pm
+++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm
@@ -58,7 +58,7 @@ sub build_domain{
my ($cdrom, $ksurl) = build_cdrom_ks_image($tck);
- my $guest = $tck->generic_domain($domain_name);
+ my $guest = $tck->generic_domain(name => $domain_name);
# change the type of network connection for 802.1Qbg tests
if ($mode eq "vepa") {
diff --git a/scripts/domain/050-transient-lifecycle.t b/scripts/domain/050-transient-lifecycle.t
index 94c6bea..d9e9ecb 100644
--- a/scripts/domain/050-transient-lifecycle.t
+++ b/scripts/domain/050-transient-lifecycle.t
@@ -40,7 +40,7 @@ BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/051-transient-autostart.t b/scripts/domain/051-transient-autostart.t
index 26ca82b..0368365 100644
--- a/scripts/domain/051-transient-autostart.t
+++ b/scripts/domain/051-transient-autostart.t
@@ -38,7 +38,7 @@ BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/060-persistent-lifecycle.t b/scripts/domain/060-persistent-lifecycle.t
index ffcb7c9..01867f9 100644
--- a/scripts/domain/060-persistent-lifecycle.t
+++ b/scripts/domain/060-persistent-lifecycle.t
@@ -39,7 +39,7 @@ BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Defining an inactive domain config";
my $dom;
diff --git a/scripts/domain/061-persistent-autostart.t b/scripts/domain/061-persistent-autostart.t
index 030515c..5f63270 100644
--- a/scripts/domain/061-persistent-autostart.t
+++ b/scripts/domain/061-persistent-autostart.t
@@ -39,7 +39,7 @@ BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Defining an inactive domain config";
my $dom;
diff --git a/scripts/domain/065-persistent-redefine.t b/scripts/domain/065-persistent-redefine.t
index af13af2..c743c6a 100644
--- a/scripts/domain/065-persistent-redefine.t
+++ b/scripts/domain/065-persistent-redefine.t
@@ -38,7 +38,7 @@ BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $cfg = $tck->generic_domain("tck")->uuid("11111111-1111-1111-1111-111111111111");
+my $cfg = $tck->generic_domain(name => "tck")->uuid("11111111-1111-1111-1111-111111111111");
$cfg->on_reboot("restart");
my $xml1 = $cfg->as_xml;
$cfg->on_reboot("destroy");
diff --git a/scripts/domain/070-transient-to-persistent.t b/scripts/domain/070-transient-to-persistent.t
index 6fea959..4ce98b9 100644
--- a/scripts/domain/070-transient-to-persistent.t
+++ b/scripts/domain/070-transient-to-persistent.t
@@ -39,7 +39,7 @@ BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/080-unique-id-define.t b/scripts/domain/080-unique-id-define.t
index 7bf23c3..7b5f2a1 100644
--- a/scripts/domain/080-unique-id-define.t
+++ b/scripts/domain/080-unique-id-define.t
@@ -54,13 +54,13 @@ my $uuid1 = "11111111-1111-1111-1111-111111111111";
my $uuid2 = "22222222-1111-1111-1111-111111111111";
# The initial config
-my $xml = $tck->generic_domain($name1)->uuid($uuid1)->as_xml;
+my $xml = $tck->generic_domain(name => $name1)->uuid($uuid1)->as_xml;
# One with a different UUID, matching name
-my $xml_diffuuid = $tck->generic_domain($name1)->uuid($uuid2)->as_xml;
+my $xml_diffuuid = $tck->generic_domain(name => $name1)->uuid($uuid2)->as_xml;
# One with a matching UUID, different name
-my $xml_diffname = $tck->generic_domain($name2)->uuid($uuid1)->as_xml;
+my $xml_diffname = $tck->generic_domain(name => $name2)->uuid($uuid1)->as_xml;
# One with a different UUID, different name
-my $xml_diffboth = $tck->generic_domain($name2)->uuid($uuid2)->as_xml;
+my $xml_diffboth = $tck->generic_domain(name => $name2)->uuid($uuid2)->as_xml;
diag "Defining persistent domain config";
diff --git a/scripts/domain/081-unique-id-create.t b/scripts/domain/081-unique-id-create.t
index 68f29c7..07143a5 100644
--- a/scripts/domain/081-unique-id-create.t
+++ b/scripts/domain/081-unique-id-create.t
@@ -54,13 +54,13 @@ my $uuid1 = "11111111-1111-1111-1111-111111111111";
my $uuid2 = "22222222-1111-1111-1111-111111111111";
# The initial config
-my $xml = $tck->generic_domain($name1)->uuid($uuid1)->as_xml;
+my $xml = $tck->generic_domain(name => $name1)->uuid($uuid1)->as_xml;
# One with a different UUID, matching name
-my $xml_diffuuid = $tck->generic_domain($name1)->uuid($uuid2)->as_xml;
+my $xml_diffuuid = $tck->generic_domain(name => $name1)->uuid($uuid2)->as_xml;
# One with a matching UUID, different name
-my $xml_diffname = $tck->generic_domain($name2)->uuid($uuid1)->as_xml;
+my $xml_diffname = $tck->generic_domain(name => $name2)->uuid($uuid1)->as_xml;
# One with a different UUID, different name
-my $xml_diffboth = $tck->generic_domain($name2)->uuid($uuid2)->as_xml;
+my $xml_diffboth = $tck->generic_domain(name => $name2)->uuid($uuid2)->as_xml;
diag "Defining persistent domain config";
my ($dom, $dom1);
diff --git a/scripts/domain/082-unique-id-caching.t b/scripts/domain/082-unique-id-caching.t
index 5ea13ed..7e0096d 100644
--- a/scripts/domain/082-unique-id-caching.t
+++ b/scripts/domain/082-unique-id-caching.t
@@ -64,9 +64,9 @@ my $uuid1 = "11111111-1111-1111-1111-111111111111";
my $uuid2 = "22222222-1111-1111-1111-111111111111";
# The initial config
-my $xml1 = $tck->generic_domain($name)->uuid($uuid1)->as_xml;
+my $xml1 = $tck->generic_domain(name => $name)->uuid($uuid1)->as_xml;
# One with a different UUID, matching name
-my $xml2 = $tck->generic_domain($name)->uuid($uuid2)->as_xml;
+my $xml2 = $tck->generic_domain(name => $name)->uuid($uuid2)->as_xml;
diag "Creating & destroying initial guest with $name, $uuid1";
my $dom1;
diff --git a/scripts/domain/090-invalid-ops-when-inactive.t b/scripts/domain/090-invalid-ops-when-inactive.t
index 38dd744..2daeee5 100644
--- a/scripts/domain/090-invalid-ops-when-inactive.t
+++ b/scripts/domain/090-invalid-ops-when-inactive.t
@@ -40,7 +40,7 @@ BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new persistent domain";
my $dom;
diff --git a/scripts/domain/100-transient-save-restore.t b/scripts/domain/100-transient-save-restore.t
index 9860fee..6ab6752 100644
--- a/scripts/domain/100-transient-save-restore.t
+++ b/scripts/domain/100-transient-save-restore.t
@@ -42,7 +42,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/101-persistent-save-restore.t b/scripts/domain/101-persistent-save-restore.t
index 5423edd..9384c23 100644
--- a/scripts/domain/101-persistent-save-restore.t
+++ b/scripts/domain/101-persistent-save-restore.t
@@ -42,7 +42,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/102-broken-save-restore.t b/scripts/domain/102-broken-save-restore.t
index a8c5d48..4a05705 100644
--- a/scripts/domain/102-broken-save-restore.t
+++ b/scripts/domain/102-broken-save-restore.t
@@ -43,7 +43,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/103-blockdev-save-restore.t b/scripts/domain/103-blockdev-save-restore.t
index 70d680c..db73e32 100644
--- a/scripts/domain/103-blockdev-save-restore.t
+++ b/scripts/domain/103-blockdev-save-restore.t
@@ -42,7 +42,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
my $dev = $tck->get_host_block_device();
diff --git a/scripts/domain/120-disks-stats.t b/scripts/domain/120-disks-stats.t
index fc18c29..b9d7be1 100644
--- a/scripts/domain/120-disks-stats.t
+++ b/scripts/domain/120-disks-stats.t
@@ -39,7 +39,7 @@ BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Defining an inactive domain config";
my $dom;
diff --git a/scripts/domain/121-block-info.t b/scripts/domain/121-block-info.t
index 0cf6500..6fa7780 100644
--- a/scripts/domain/121-block-info.t
+++ b/scripts/domain/121-block-info.t
@@ -85,7 +85,7 @@ my $disktype = "raw";
my $dst = "vda";
my $dst2 = "vdb";
my $dst3 = "vdc";
-my $guest = $tck->generic_domain("tck");
+my $guest = $tck->generic_domain(name => "tck");
$guest->rmdisk();
$guest->disk(format => { name => "qemu", type => $disktype }, type => "file", src => $path, dst => $dst);
diff --git a/scripts/domain/130-cpu-hotplug.t b/scripts/domain/130-cpu-hotplug.t
index 0ff1fc5..f735e73 100644
--- a/scripts/domain/130-cpu-hotplug.t
+++ b/scripts/domain/130-cpu-hotplug.t
@@ -41,7 +41,7 @@ BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
diff --git a/scripts/domain/180-interface-parameters.t b/scripts/domain/180-interface-parameters.t
index cfe6cdb..d7866c0 100644
--- a/scripts/domain/180-interface-parameters.t
+++ b/scripts/domain/180-interface-parameters.t
@@ -47,7 +47,7 @@ END {
my $live = $conn->is_alive();
ok($live > 0, "Connection is alive");
-my $xml = $tck->generic_domain("tck")
+my $xml = $tck->generic_domain(name => "tck")
->interface(type => "network", source => "default", model => "virtio", mac => "52:54:00:22:22:22")
->as_xml;
diff --git a/scripts/domain/200-disk-hotplug.t b/scripts/domain/200-disk-hotplug.t
index fe12d72..4c54b6b 100644
--- a/scripts/domain/200-disk-hotplug.t
+++ b/scripts/domain/200-disk-hotplug.t
@@ -41,7 +41,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/202-numa-set-parameters.t b/scripts/domain/202-numa-set-parameters.t
index fd96866..c0baf0b 100644
--- a/scripts/domain/202-numa-set-parameters.t
+++ b/scripts/domain/202-numa-set-parameters.t
@@ -42,7 +42,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new persistent domain";
my $dom;
diff --git a/scripts/domain/205-disk-hotplug-ordering.t b/scripts/domain/205-disk-hotplug-ordering.t
index be0487a..bc4990f 100644
--- a/scripts/domain/205-disk-hotplug-ordering.t
+++ b/scripts/domain/205-disk-hotplug-ordering.t
@@ -41,7 +41,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/207-disk-media-change.t b/scripts/domain/207-disk-media-change.t
index ad1756d..dfef7c9 100644
--- a/scripts/domain/207-disk-media-change.t
+++ b/scripts/domain/207-disk-media-change.t
@@ -46,7 +46,7 @@ my $path2 = $tck->create_sparse_disk("207-disk-media-change", "extra2.img", 100)
my $xml;
eval {
- $xml = $tck->generic_domain("tck", "hvm")
+ $xml = $tck->generic_domain(name => "tck", ostype => "hvm")
->disk(src => $path1, dst => "hdc", type => "file", device => "cdrom")
->as_xml;
};
diff --git a/scripts/domain/210-nic-hotplug.t b/scripts/domain/210-nic-hotplug.t
index 593a92d..ac9048e 100644
--- a/scripts/domain/210-nic-hotplug.t
+++ b/scripts/domain/210-nic-hotplug.t
@@ -41,7 +41,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/215-nic-hotplug-many.t b/scripts/domain/215-nic-hotplug-many.t
index 5b935cc..0270054 100644
--- a/scripts/domain/215-nic-hotplug-many.t
+++ b/scripts/domain/215-nic-hotplug-many.t
@@ -41,7 +41,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/240-usb-host-hotplug.t b/scripts/domain/240-usb-host-hotplug.t
index 6e74434..a840298 100644
--- a/scripts/domain/240-usb-host-hotplug.t
+++ b/scripts/domain/240-usb-host-hotplug.t
@@ -43,7 +43,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/250-pci-host-hotplug.t b/scripts/domain/250-pci-host-hotplug.t
index a9fe422..4579477 100644
--- a/scripts/domain/250-pci-host-hotplug.t
+++ b/scripts/domain/250-pci-host-hotplug.t
@@ -47,7 +47,7 @@ END {
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
diff --git a/scripts/domain/300-migration.t b/scripts/domain/300-migration.t
index 9cbdd8f..4e91668 100644
--- a/scripts/domain/300-migration.t
+++ b/scripts/domain/300-migration.t
@@ -100,7 +100,7 @@ my ($conn, $otherconn) = eval { $tck->setup(dualhost => 1); };
BAIL_OUT "failed to setup test harness: $@" if $@;
END { $tck->cleanup if $tck; }
-my $xml = $tck->generic_domain("tck")->uuid("050072e8-7bce-3515-992a-8431d74f371f")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->uuid("050072e8-7bce-3515-992a-8431d74f371f")->as_xml;
use Sys::Virt::Domain;
use IO::File;
diff --git a/scripts/domain/301-migration-max-speed.t b/scripts/domain/301-migration-max-speed.t
index cd029c2..6aac931 100644
--- a/scripts/domain/301-migration-max-speed.t
+++ b/scripts/domain/301-migration-max-speed.t
@@ -42,7 +42,7 @@ END {
$tck->cleanup if $tck;
}
-my $xml = $tck->generic_domain("tck")->as_xml;
+my $xml = $tck->generic_domain(name => "tck")->as_xml;
my $dom;
ok_domain(sub { $dom = $conn->create_domain($xml) }, "Create domain");
diff --git a/scripts/hooks/052-domain-hook.t b/scripts/hooks/052-domain-hook.t
index 90b8a48..294b30d 100644
--- a/scripts/hooks/052-domain-hook.t
+++ b/scripts/hooks/052-domain-hook.t
@@ -49,7 +49,7 @@ SKIP: {
skip 12, "Not using QEMU/LXC driver" unless
$uri eq "qemu:///system" or $uri eq "lxc:///";
- my $xml = $tck->generic_domain("tck")->as_xml;
+ my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new persistent domain";
my $dom;
diff --git a/scripts/qemu/100-disk-encryption.t b/scripts/qemu/100-disk-encryption.t
index 5fb6fc8..8a0fd5e 100644
--- a/scripts/qemu/100-disk-encryption.t
+++ b/scripts/qemu/100-disk-encryption.t
@@ -84,7 +84,7 @@ my $vol;
diag "Creating volume $volXML";
lives_ok(sub { $vol = $pool->create_volume($volXML) }, "volume created");
-my $xml = $tck->generic_domain("tck")
+my $xml = $tck->generic_domain(name => "tck")
->disk(format => { name => "qemu", type => "qcow2" },
secret => $secretUUID,
type => "file",
diff --git a/scripts/qemu/200-qcow2-single-backing-file.t b/scripts/qemu/200-qcow2-single-backing-file.t
index 1cc665f..28d27c2 100644
--- a/scripts/qemu/200-qcow2-single-backing-file.t
+++ b/scripts/qemu/200-qcow2-single-backing-file.t
@@ -107,7 +107,7 @@ SKIP: {
# We point the guest at a qcow2 image, but tell it that is
# is raw. Thus *nothing* should ever try to open the backing
# store in this qcow2 image.
- $xml = $tck->generic_domain("tck")
+ $xml = $tck->generic_domain(name => "tck")
->disk(format => { name => "qemu", type => "raw" },
type => "file",
src => $pathmain,
diff --git a/scripts/qemu/205-qcow2-double-backing-file.t b/scripts/qemu/205-qcow2-double-backing-file.t
index ad54c7c..485b6f7 100644
--- a/scripts/qemu/205-qcow2-double-backing-file.t
+++ b/scripts/qemu/205-qcow2-double-backing-file.t
@@ -132,7 +132,7 @@ SKIP: {
# We point the guest at a qcow2 image, but tell it that is
# is raw. Thus *nothing* should ever try to open the backing
# store in this qcow2 image.
- $xml = $tck->generic_domain("tck")
+ $xml = $tck->generic_domain(name => "tck")
->disk(format => { name => "qemu", type => "qcow2" },
type => "file",
src => $pathmain,
diff --git a/scripts/qemu/210-qcow2-auto-probing.t b/scripts/qemu/210-qcow2-auto-probing.t
index bf3de32..5ed4761 100644
--- a/scripts/qemu/210-qcow2-auto-probing.t
+++ b/scripts/qemu/210-qcow2-auto-probing.t
@@ -129,7 +129,7 @@ SKIP: {
# We point the guest at a qcow2 image, but tell it that is
# is raw. Thus *nothing* should ever try to open the backing
# store in this qcow2 image.
- $xml = $tck->generic_domain("tck")
+ $xml = $tck->generic_domain(name => "tck")
->disk(type => "file",
src => $pathmain,
dst => "vdb")
diff --git a/scripts/qemu/400-save-image-xml.t b/scripts/qemu/400-save-image-xml.t
index df87666..e7b96b7 100644
--- a/scripts/qemu/400-save-image-xml.t
+++ b/scripts/qemu/400-save-image-xml.t
@@ -47,7 +47,7 @@ SKIP:{
skip "Only relevant to QEMU driver", 10 unless $conn->get_type() eq "QEMU";
# scenario 1 - get/define xml from transient domain save image
- my $xml = $tck->generic_domain("tck")->as_xml;
+ my $xml = $tck->generic_domain(name => "tck")->as_xml;
diag "Creating a new transient domain";
my $dom;
ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
diff --git a/scripts/selinux/050-dynamic-relabel-yes.t b/scripts/selinux/050-dynamic-relabel-yes.t
index 6a75f92..2fb6866 100644
--- a/scripts/selinux/050-dynamic-relabel-yes.t
+++ b/scripts/selinux/050-dynamic-relabel-yes.t
@@ -51,7 +51,7 @@ SKIP: {
my $origlabel = selinux_restore_file_context($disk);
diag "Original $origlabel";
- my $xml = $tck->generic_domain("tck")
+ my $xml = $tck->generic_domain(name => "tck")
->seclabel(model => "selinux", type => "dynamic", relabel => "yes")
->disk(src => $disk, dst => "vdb", type => "file")
->as_xml;
diff --git a/scripts/selinux/055-dynamic-base-label.t b/scripts/selinux/055-dynamic-base-label.t
index 271c2e9..ba07c09 100644
--- a/scripts/selinux/055-dynamic-base-label.t
+++ b/scripts/selinux/055-dynamic-base-label.t
@@ -51,7 +51,7 @@ SKIP: {
my $origlabel = selinux_restore_file_context($disk);
- my $xml = $tck->generic_domain("tck")
+ my $xml = $tck->generic_domain(name => "tck")
->seclabel(model => "selinux", type => "dynamic", relabel => "yes", baselabel => $SELINUX_OTHER_CONTEXT)
->disk(src => $disk, dst => "vdb", type => "file")
->as_xml;
diff --git a/scripts/selinux/100-static-relabel-no.t b/scripts/selinux/100-static-relabel-no.t
index 30db172..36eae47 100644
--- a/scripts/selinux/100-static-relabel-no.t
+++ b/scripts/selinux/100-static-relabel-no.t
@@ -53,7 +53,7 @@ SKIP: {
selinux_set_file_context($disk, $origimagelabel);
- my $xml = $tck->generic_domain("tck")
+ my $xml = $tck->generic_domain(name => "tck")
->seclabel(model => "selinux", type => "static", relabel => "no", label => $origdomainlabel)
->disk(src => $disk, dst => "vdb", type => "file")
->as_xml;
diff --git a/scripts/selinux/105-static-relabel-fail.t b/scripts/selinux/105-static-relabel-fail.t
index 08ef429..20b576e 100644
--- a/scripts/selinux/105-static-relabel-fail.t
+++ b/scripts/selinux/105-static-relabel-fail.t
@@ -53,7 +53,7 @@ SKIP: {
my $origdomainlabel = $SELINUX_DOMAIN_CONTEXT . $origmcs;
my $origimagelabel = selinux_restore_file_context($disk);
- my $xml = $tck->generic_domain("tck")
+ my $xml = $tck->generic_domain(name => "tck")
->seclabel(model => "selinux", type => "static", relabel => "no", label => $origdomainlabel)
->disk(src => $disk, dst => "vdb", type => "file")
->as_xml;
diff --git a/scripts/selinux/110-static-relabel-yes.t b/scripts/selinux/110-static-relabel-yes.t
index deba314..dc4e1ec 100644
--- a/scripts/selinux/110-static-relabel-yes.t
+++ b/scripts/selinux/110-static-relabel-yes.t
@@ -52,7 +52,7 @@ SKIP: {
my $origdomainlabel = $SELINUX_DOMAIN_CONTEXT . $origmcs;
my $origimagelabel = selinux_restore_file_context($disk);
- my $xml = $tck->generic_domain("tck")
+ my $xml = $tck->generic_domain(name => "tck")
->seclabel(model => "selinux", type => "static", relabel => "yes", label => $origdomainlabel)
->disk(src => $disk, dst => "vdb", type => "file")
->as_xml;
--
1.8.5.3
10 years, 8 months
[libvirt] [PATCH] Do not truncate output of nwfilter2vmtest.sh
by Daniel P. Berrange
When printing test results, nwfilter2vmtest.sh, truncates
the output at 66 or 70 characters. This is very unhelpful
when debugging problems where you want to see the full
output
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
scripts/nwfilter/nwfilter2vmtest.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/nwfilter/nwfilter2vmtest.sh b/scripts/nwfilter/nwfilter2vmtest.sh
index f44f299..a68c771 100644
--- a/scripts/nwfilter/nwfilter2vmtest.sh
+++ b/scripts/nwfilter/nwfilter2vmtest.sh
@@ -68,7 +68,7 @@ EOF
tap_fail() {
- txt=$(echo "$2" | gawk '{print substr($0,1,66)}')
+ txt=$(echo "$2")
echo "not ok $1 - ${txt}"
TAP_FAIL_LIST="$TAP_FAIL_LIST $1 "
TAP_FAIL_CTR=$(($TAP_FAIL_CTR + 1))
@@ -76,7 +76,7 @@ tap_fail() {
}
tap_pass() {
- txt=$(echo "$2" | gawk '{print substr($0,1,70)}')
+ txt=$(echo "$2")
echo "ok $1 - ${txt}"
TAP_TOT_CTR=$(($TAP_TOT_CTR + 1))
}
--
1.8.5.3
10 years, 8 months
[libvirt] [PATCH] Added example script on how to convert LXC container config
by Cédric Bosdonnat
---
Makefile.am | 2 +-
configure.ac | 1 +
examples/lxcconvert/Makefile.am | 19 ++++++++++
examples/lxcconvert/virt-lxc-convert | 67 ++++++++++++++++++++++++++++++++++++
4 files changed, 88 insertions(+), 1 deletion(-)
create mode 100644 examples/lxcconvert/Makefile.am
create mode 100644 examples/lxcconvert/virt-lxc-convert
diff --git a/Makefile.am b/Makefile.am
index 9847ff0..0ef983f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,7 @@ SUBDIRS = . gnulib/lib include src daemon tools docs gnulib/tests \
tests po examples/object-events examples/hellolibvirt \
examples/dominfo examples/domsuspend examples/apparmor \
examples/xml/nwfilter examples/openauth examples/systemtap \
- tools/wireshark
+ examples/lxcconvert tools/wireshark
ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index 62b74c5..f970de0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2695,6 +2695,7 @@ AC_CONFIG_FILES([\
examples/hellolibvirt/Makefile \
examples/systemtap/Makefile \
examples/xml/nwfilter/Makefile \
+ examples/lxcconvert/Makefile \
tools/wireshark/Makefile \
tools/wireshark/src/Makefile])
AC_OUTPUT
diff --git a/examples/lxcconvert/Makefile.am b/examples/lxcconvert/Makefile.am
new file mode 100644
index 0000000..c5ae537
--- /dev/null
+++ b/examples/lxcconvert/Makefile.am
@@ -0,0 +1,19 @@
+## Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library. If not, see
+## <http://www.gnu.org/licenses/>.
+
+EXTRA_DIST= \
+ virt-lxc-convert
+
diff --git a/examples/lxcconvert/virt-lxc-convert b/examples/lxcconvert/virt-lxc-convert
new file mode 100644
index 0000000..ea32ff4
--- /dev/null
+++ b/examples/lxcconvert/virt-lxc-convert
@@ -0,0 +1,67 @@
+#!/usr/bin/env sh
+
+function show_help()
+{
+ cat << EOF
+$0 /path/to/lxc/config/file
+
+Wrapper around virsh domxml-from-native to ease conversion of LXC
+containers configuration to libvirt domain XML.
+EOF
+}
+
+if test "$#" != 1; then
+ show_help
+ exit 1
+fi
+
+conf=$1
+
+
+conf_new=/tmp/config-$$
+domain_new=/tmp/config-$$.xml
+
+cp $conf $conf_new
+
+# Do we have lxc.mount, and is it pointing to a readable file?
+fstab=`grep 'lxc.mount[[:space:]]*=' $conf_new | sed -e 's/[[:space:]]\+=[[:space:]]\+/=/' | cut -f 2 -d '='`
+if test \( -n "$fstab" \) -a \( -r "$fstab" \); then
+ sed -i -e 's/^lxc.mount[[:space:]]*=.*$//' $conf_new
+ sed -e 's/^\([^#]\)/lxc.mount.entry = \1/' $fstab | cat $conf_new - >${conf_new}.tmp
+ mv ${conf_new}.tmp $conf_new
+fi
+
+memory=`free | grep 'Mem:' | sed -e 's: \+: :g' | cut -f 2 -d ' '`
+default_tmpfs="size=$((memory/2))"
+
+# Do we have tmpfs without size param?
+grep -e 'lxc.mount.entry[[:space:]]*=[[:space:]]*tmpfs[[:space:]]' $conf_new | while read line; do
+ has_size=`echo $line | grep -v -e 'size='`
+ # Add the default size here (50%) if no size is given
+ if test -n "$has_size"; then
+ sed -i -e "\;$line;s/\([[:space:]]\+[0-9][[:space:]]\+[0-9][::space::]*$\)/,$default_tmpfs\1/" $conf_new
+ fi
+ # Convert relative sizes
+ has_rel_size=`echo $line | grep -e 'size=[0-9]\+%'`
+ if test -n "$has_rel_size"; then
+ percent=`echo "$line" | sed -e 's:size=\([0-9]\+\)%:\n\1%\n:' | grep '\%' | sed -e 's/%//'`
+ size="$((memory*percent/100))"
+ sed -i -e "\;$line;s/size=[0-9]\+%/size=${size}/" $conf_new
+ fi
+done
+
+# Do we have any memory limit set?
+mem_limit=`grep 'lxc.cgroup.memory.limit_in_bytes[[:space:]]*=' $conf_new`
+if test -z "$mem_limit"; then
+ sed -i -e "1s:^:lxc.cgroup.memory.limit_in_bytes = $memory\n:" $conf_new
+fi
+
+virsh -c lxc:/// domxml-from-native lxc-tools $conf_new >$domain_new
+
+cat $domain_new
+
+# Remove the temporary config
+rm $conf_new
+rm $domain_new
+
+exit 0
--
1.9.0
10 years, 8 months
[libvirt] [PATCH tck] Avoid assumptions about selinux contexts
by Daniel P. Berrange
The current SELinux tests assume a context system_u:system_r
or system_u:object_r, which is not true if running against
a libvirtd from the source tree.
---
lib/Sys/Virt/TCK/SELinux.pm | 30 +++++++++++++++++++++++++++---
scripts/selinux/050-dynamic-relabel-yes.t | 10 ++++++----
scripts/selinux/055-dynamic-base-label.t | 10 ++++++----
scripts/selinux/100-static-relabel-no.t | 2 +-
scripts/selinux/110-static-relabel-yes.t | 11 +++++++----
5 files changed, 47 insertions(+), 16 deletions(-)
diff --git a/lib/Sys/Virt/TCK/SELinux.pm b/lib/Sys/Virt/TCK/SELinux.pm
index 9f7c0c1..c117fca 100644
--- a/lib/Sys/Virt/TCK/SELinux.pm
+++ b/lib/Sys/Virt/TCK/SELinux.pm
@@ -18,19 +18,43 @@ use warnings;
use base qw(Exporter);
use vars qw($SELINUX_GENERIC_CONTEXT $SELINUX_DOMAIN_CONTEXT
- $SELINUX_IMAGE_CONTEXT $SELINUX_OTHER_CONTEXT);
+ $SELINUX_IMAGE_CONTEXT $SELINUX_OTHER_CONTEXT
+ $SELINUX_GENERIC_TYPE $SELINUX_DOMAIN_TYPE
+ $SELINUX_IMAGE_TYPE $SELINUX_OTHER_TYPE);
our @EXPORT = qw(selinux_get_file_context
selinux_set_file_context
selinux_restore_file_context
+ selinux_get_type
+ selinux_get_mcs
$SELINUX_GENERIC_CONTEXT $SELINUX_DOMAIN_CONTEXT
- $SELINUX_IMAGE_CONTEXT $SELINUX_OTHER_CONTEXT);
+ $SELINUX_IMAGE_CONTEXT $SELINUX_OTHER_CONTEXT
+ $SELINUX_GENERIC_TYPE $SELINUX_DOMAIN_TYPE
+ $SELINUX_IMAGE_TYPE $SELINUX_OTHER_TYPE);
-$SELINUX_OTHER_CONTEXT = "system_u:object_r:virt_t:s0";
+$SELINUX_OTHER_TYPE = "svirt_tcg_t";
+$SELINUX_GENERIC_TYPE = "virt_image_t";
+$SELINUX_DOMAIN_TYPE = "svirt_t";
+$SELINUX_IMAGE_TYPE = "svirt_image_t";
+
+$SELINUX_OTHER_CONTEXT = "system_u:system_r:svirt_tcg_t:s0";
$SELINUX_GENERIC_CONTEXT = "system_u:object_r:virt_image_t:s0";
$SELINUX_DOMAIN_CONTEXT = "system_u:system_r:svirt_t:s0";
$SELINUX_IMAGE_CONTEXT = "system_u:object_r:svirt_image_t:s0";
+sub selinux_get_type {
+ my $context = shift;
+
+ my @bits = split /:/, $context;
+ return $bits[2];
+}
+
+sub selinux_get_mcs {
+ my $context = shift;
+
+ my @bits = split /:/, $context;
+ return $bits[4];
+}
sub selinux_get_file_context {
my $path = shift;
diff --git a/scripts/selinux/050-dynamic-relabel-yes.t b/scripts/selinux/050-dynamic-relabel-yes.t
index 2fb6866..5a53b9d 100644
--- a/scripts/selinux/050-dynamic-relabel-yes.t
+++ b/scripts/selinux/050-dynamic-relabel-yes.t
@@ -64,12 +64,14 @@ SKIP: {
diag "domainlabel $domainlabel";
my $imagelabel = xpath($dom, "string(/domain/seclabel/imagelabel)");
diag "imagelabel $imagelabel";
+ my $domaintype = selinux_get_type($domainlabel);
+ my $imagetype = selinux_get_type($imagelabel);
- is(index($domainlabel, $SELINUX_DOMAIN_CONTEXT), 0, "dynamic domain label prefix is $SELINUX_DOMAIN_CONTEXT");
- is(index($imagelabel, $SELINUX_IMAGE_CONTEXT), 0, "dynamic image label prefix is $SELINUX_IMAGE_CONTEXT");
+ is($domaintype, $SELINUX_DOMAIN_TYPE, "dynamic domain label type is $SELINUX_DOMAIN_TYPE");
+ is($imagetype, $SELINUX_IMAGE_TYPE, "dynamic image label type is $SELINUX_IMAGE_TYPE");
- my $domainmcs = substr $domainlabel, length($SELINUX_DOMAIN_CONTEXT);
- my $imagemcs = substr $imagelabel, length($SELINUX_IMAGE_CONTEXT);
+ my $domainmcs = selinux_get_mcs($domainlabel);
+ my $imagemcs = selinux_get_mcs($imagelabel);
is($domainmcs, $imagemcs, "Domain MCS $domainmcs == Image MCS $imagemcs");
diff --git a/scripts/selinux/055-dynamic-base-label.t b/scripts/selinux/055-dynamic-base-label.t
index ba07c09..646c50d 100644
--- a/scripts/selinux/055-dynamic-base-label.t
+++ b/scripts/selinux/055-dynamic-base-label.t
@@ -64,12 +64,14 @@ SKIP: {
diag "domainlabel $domainlabel";
my $imagelabel = xpath($dom, "string(/domain/seclabel/imagelabel)");
diag "imagelabel $imagelabel";
+ my $domaintype = selinux_get_type($domainlabel);
+ my $imagetype = selinux_get_type($imagelabel);
- is(index($domainlabel, $SELINUX_OTHER_CONTEXT), 0, "dynamic domain label prefix is $SELINUX_OTHER_CONTEXT");
- is(index($imagelabel, $SELINUX_IMAGE_CONTEXT), 0, "dynamic image label prefix is $SELINUX_IMAGE_CONTEXT");
+ is($domaintype, $SELINUX_OTHER_TYPE, "dynamic domain label type is $SELINUX_OTHER_TYPE");
+ is($imagetype, $SELINUX_IMAGE_TYPE, "dynamic image label type is $SELINUX_IMAGE_TYPE");
- my $domainmcs = substr $domainlabel, length($SELINUX_OTHER_CONTEXT);
- my $imagemcs = substr $imagelabel, length($SELINUX_IMAGE_CONTEXT);
+ my $domainmcs = selinux_get_mcs($domainlabel);
+ my $imagemcs = selinux_get_mcs($imagelabel);
is($domainmcs, $imagemcs, "Domain MCS $domainmcs == Image MCS $imagemcs");
diff --git a/scripts/selinux/100-static-relabel-no.t b/scripts/selinux/100-static-relabel-no.t
index 36eae47..8d9fda8 100644
--- a/scripts/selinux/100-static-relabel-no.t
+++ b/scripts/selinux/100-static-relabel-no.t
@@ -51,8 +51,8 @@ SKIP: {
my $origdomainlabel = $SELINUX_DOMAIN_CONTEXT . $origmcs;
my $origimagelabel = $SELINUX_IMAGE_CONTEXT . $origmcs;
+ diag "Setting image '$disk' to '$origimagelabel'";
selinux_set_file_context($disk, $origimagelabel);
-
my $xml = $tck->generic_domain(name => "tck")
->seclabel(model => "selinux", type => "static", relabel => "no", label => $origdomainlabel)
->disk(src => $disk, dst => "vdb", type => "file")
diff --git a/scripts/selinux/110-static-relabel-yes.t b/scripts/selinux/110-static-relabel-yes.t
index dc4e1ec..f558cc9 100644
--- a/scripts/selinux/110-static-relabel-yes.t
+++ b/scripts/selinux/110-static-relabel-yes.t
@@ -28,7 +28,7 @@ and files can be relabelled
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 6;
use Sys::Virt::TCK;
use Sys::Virt::TCK::SELinux;
@@ -48,8 +48,8 @@ SKIP: {
my $disk = $tck->create_sparse_disk("selinux", "tck", 50);
- my $origmcs = ":c1,c2";
- my $origdomainlabel = $SELINUX_DOMAIN_CONTEXT . $origmcs;
+ my $origmcs = "c1,c2";
+ my $origdomainlabel = $SELINUX_DOMAIN_CONTEXT . ":" . $origmcs;
my $origimagelabel = selinux_restore_file_context($disk);
my $xml = $tck->generic_domain(name => "tck")
@@ -66,9 +66,12 @@ SKIP: {
diag "domainlabel $domainlabel";
my $imagelabel = xpath($dom, "string(/domain/seclabel/imagelabel)");
diag "imagelabel $imagelabel";
+ my $imagetype = selinux_get_type($imagelabel);
+ my $imagemcs = selinux_get_mcs($imagelabel);
is($origdomainlabel, $domainlabel, "static label is $domainlabel");
- is($imagelabel, $SELINUX_IMAGE_CONTEXT . $origmcs, "image label is $SELINUX_DOMAIN_CONTEXT$origmcs");
+ is($imagetype, $SELINUX_IMAGE_TYPE, "image label type is $SELINUX_DOMAIN_TYPE");
+ is($imagemcs, $origmcs, "image label mcs is $origmcs");
is(selinux_get_file_context($disk), $imagelabel, "$disk label is $imagelabel");
--
1.8.5.3
10 years, 8 months
[libvirt] Crash when using python-libvirt setSchedulerParameters
by Brian Rak
I'm seeing a very weird (and somewhat reproducable) crash in
setSchedulerParameters. The backtrace looks like this:
*** glibc detected *** python2.7: free(): invalid pointer:
0x000000000152bc48 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x76166)[0x7faa9e991166]
/usr/lib64/python2.7/site-packages/libvirtmod.so(virFree+0x29)[0x7faa9887bfe9]
/lib/libvirt.so.0(virTypedParamsClear+0x54)[0x7faa98342fe4]
/lib/libvirt.so.0(virTypedParamsFree+0x1e)[0x7faa9834302e]
/usr/lib64/python2.7/site-packages/libvirtmod.so(+0x1b4dc)[0x7faa9886c4dc]
/usr/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x5629)[0x7faa9f63a129]
/usr/lib64/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x68e8)[0x7faa9f63b3e8]
/usr/lib64/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x8ae)[0x7faa9f63bd5e]
/usr/lib64/libpython2.7.so.1.0(PyEval_EvalCode+0x32)[0x7faa9f63be72]
/usr/lib64/libpython2.7.so.1.0(+0xff25c)[0x7faa9f65625c]
/usr/lib64/libpython2.7.so.1.0(PyRun_FileExFlags+0x90)[0x7faa9f656330]
/usr/lib64/libpython2.7.so.1.0(PyRun_SimpleFileExFlags+0xef)[0x7faa9f6578cf]
/usr/lib64/libpython2.7.so.1.0(Py_Main+0xc56)[0x7faa9f6693f6]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x7faa9e939d1d]
python2.7[0x400649]
I am using:
Python2.7
Python-Libvirt 1.2.2 with the "[PATCH libvirt-python 1/2]
setPyVirTypedParameter: Copy full field name" patch.
Libvirt 1.2.1
A quick example:
import libvirt
for i in range(0,40):
conn = libvirt.open(None)
for domid in conn.listDomainsID():
dom = conn.lookupByID(domid)
print dom.name()
params = {}
params['vcpu_period'] = 50000
params['vcpu_quota'] = 100000
dom.setSchedulerParameters(params)
This will crash frequently (over 80% of the time), but not all the
time. Interestingly, if I add 'dom = None' before 'conn =
libvirt.open(None)', the crashes seem to stop.
This is just a simple test case from my actual application though, so
applying that workaround may be tough (and it seems like it shouldn't
crash, even without that.
10 years, 8 months
[libvirt] [PATCH v2] Fix apparmor profile to make vfio pci passthrough work
by Cédric Bosdonnat
See lp#1276719 for the bug description. As virt-aa-helper doesn't know
the VFIO groups to use for the guest, allow access to all
/dev/vfio/[0-9]* and /dev/vfio/vfio files if there is a potential need
for vfio
---
examples/apparmor/libvirt-qemu | 1 +
examples/apparmor/usr.sbin.libvirtd | 3 +++
src/security/virt-aa-helper.c | 12 ++++++++++++
3 files changed, 16 insertions(+)
diff --git a/examples/apparmor/libvirt-qemu b/examples/apparmor/libvirt-qemu
index e1980b7..83814ec 100644
--- a/examples/apparmor/libvirt-qemu
+++ b/examples/apparmor/libvirt-qemu
@@ -110,6 +110,7 @@
/usr/bin/qemu-sparc32plus rmix,
/usr/bin/qemu-sparc64 rmix,
/usr/bin/qemu-x86_64 rmix,
+ /usr/lib/qemu/block-curl.so mr,
# for save and resume
/bin/dash rmix,
diff --git a/examples/apparmor/usr.sbin.libvirtd b/examples/apparmor/usr.sbin.libvirtd
index fd6def1..3011eff 100644
--- a/examples/apparmor/usr.sbin.libvirtd
+++ b/examples/apparmor/usr.sbin.libvirtd
@@ -25,6 +25,9 @@
capability fsetid,
capability audit_write,
+ # Needed for vfio
+ capability sys_resource,
+
network inet stream,
network inet dgram,
network inet6 stream,
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 59de517..998dc53 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -927,6 +927,7 @@ get_files(vahControl * ctl)
size_t i;
char *uuid;
char uuidstr[VIR_UUID_STRING_BUFLEN];
+ bool needsVfio = false;
/* verify uuid is same as what we were given on the command line */
virUUIDFormat(ctl->def->uuid, uuidstr);
@@ -1068,6 +1069,12 @@ get_files(vahControl * ctl)
dev->source.subsys.u.pci.addr.slot,
dev->source.subsys.u.pci.addr.function);
+ virDomainHostdevSubsysPciBackendType backend = dev->source.subsys.u.pci.backend;
+ if (backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO ||
+ backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) {
+ needsVfio = true;
+ }
+
if (pci == NULL)
continue;
@@ -1096,6 +1103,11 @@ get_files(vahControl * ctl)
}
}
+ if (needsVfio) {
+ virBufferAsprintf(&buf, " /dev/vfio/vfio rw,\n");
+ virBufferAsprintf(&buf, " /dev/vfio/[0-9]* rw,\n");
+ }
+
if (ctl->newfile)
if (vah_add_file(&buf, ctl->newfile, "rw") != 0)
goto cleanup;
--
1.9.0
10 years, 8 months
[libvirt] [PATCH 0/2] apparmor fixes
by Cédric Bosdonnat
Fixes a regression I brough in virt-aa-helper with the lxc apparmor profiles.
And makes vfio work even with apparmor enforced on libvirtd
Cédric Bosdonnat (2):
Fixed regression in apparmor profiles for qemu brought by 43c030f
Fix apparmor profile to make vfio pci passthrough work
examples/apparmor/libvirt-qemu | 5 +++++
examples/apparmor/usr.sbin.libvirtd | 3 +++
src/security/virt-aa-helper.c | 4 +++-
3 files changed, 11 insertions(+), 1 deletion(-)
--
1.9.0
10 years, 8 months
[libvirt] VM host name
by Vikas Kokare
Is there a way using LibVirt (java) API to find out the DNS host name of a
virtual machine, if already configured?
-Vikas
10 years, 8 months
[libvirt] [PATCH 0/3] ABI change: change group name of option table to match with option name
by Amos Kong
This patchset changes group names of option tables to match with option name,
this breakes ABI, release note was updated.
Amos Kong (3):
only add qemu_tpmdev_opts when CONFIG_TPM is defined
abort QEMU if group name in option table doesn't match with defined
option name
update names in option tables to match with actual command-line
spelling
hw/acpi/core.c | 8 ++++----
hw/nvram/fw_cfg.c | 4 ++--
include/qemu/option.h | 2 +-
qemu-options.h | 12 ++++++++++++
util/qemu-config.c | 28 ++++++++++++++++++++++++++++
vl.c | 37 +++++++++++++------------------------
6 files changed, 60 insertions(+), 31 deletions(-)
--
1.8.5.3
10 years, 8 months