[libvirt] [TCK PATCH] maint: remove duplicate file
by Eric Blake
File is a duplicate of 14f3792:lib/Sys/Virt/TCK.pm. Besides, it
is already exluded by MANIFEST.SKIP.
* lib/Sys/Virt/TCK.pm.orig: Delete.
* .gitignore: Sort. Add *.orig.
---
.gitignore | 25 +-
lib/Sys/Virt/TCK.pm.orig | 766 ----------------------------------------------
2 files changed, 13 insertions(+), 778 deletions(-)
delete mode 100644 lib/Sys/Virt/TCK.pm.orig
diff --git a/.gitignore b/.gitignore
index 2c7ac91..cc1470e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,18 +1,19 @@
+#.*#
+*.bak
+*.orig
*~
-pm_to_blib
+Build
+MANIFEST
+META.yml
Makefile
+Makefile.PL
Makefile.old
-#.*#
-blib/
Sys-Virt-TCK-*
-MANIFEST
-*.bak
-results/
-data/
-META.yml
-cover_db/
_build/
-perl-Sys-Virt-TCK.spec
-Build
-Makefile.PL
+blib/
+cover_db/
+data/
libvirt-tck
+perl-Sys-Virt-TCK.spec
+pm_to_blib
+results/
diff --git a/lib/Sys/Virt/TCK.pm.orig b/lib/Sys/Virt/TCK.pm.orig
deleted file mode 100644
index 909ddd8..0000000
--- a/lib/Sys/Virt/TCK.pm.orig
+++ /dev/null
@@ -1,766 +0,0 @@
-
-package Sys::Virt::TCK;
-
-use strict;
-use warnings;
-
-use Sys::Virt;
-use Sys::Virt::TCK::DomainBuilder;
-use Sys::Virt::TCK::NetworkBuilder;
-use Sys::Virt::TCK::StoragePoolBuilder;
-use Sys::Virt::TCK::StorageVolBuilder;
-use Sys::Virt::TCK::Capabilities;
-
-use Config::Record;
-use File::Copy qw(copy);
-use File::Path qw(mkpath);
-use File::Spec::Functions qw(catfile catdir rootdir);
-use Cwd qw(cwd);
-use LWP::UserAgent;
-use IO::Uncompress::Gunzip qw(gunzip);
-use IO::Uncompress::Bunzip2 qw(bunzip2);
-use XML::XPath;
-use Carp qw(cluck carp);
-
-use Test::Builder;
-use Sub::Uplevel qw(uplevel);
-use base qw(Exporter);
-
-our @EXPORT = qw(ok_error ok_domain ok_pool ok_volume xpath err_not_implemented);
-
-our $VERSION = '0.1.0';
-
-sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = {};
- my %params = @_;
-
- $self->{config} = $params{config} ? $params{config} :
- Config::Record->new(file => ($ENV{LIBVIRT_TCK_CONFIG} || "/etc/tck.conf"));
-
- $self->{autoclean} = $params{autoclean} ? $params{autoclean} :
- ($ENV{LIBVIRT_TCK_AUTOCLEAN} || 0);
-
- if ($ENV{LIBVIRT_TCK_DEBUG}) {
- $SIG{__WARN__} = sub { Carp::cluck $_[0]; };
- $SIG{__DIE__} = sub { Carp::confess $_[0]; };
- }
-
- bless $self, $class;
-
- return $self;
-}
-
-
-sub setup {
- my $self = shift;
-
- my $uri = $self->config("uri", undef);
- $self->{conn} = Sys::Virt->new(address => $uri);
- my $type = $self->{conn}->get_type();
- $self->{type} = lc $type;
-
- $self->reset if $self->{autoclean};
-
- $self->sanity_check;
-
- return $self->{conn};
-}
-
-
-sub sanity_check {
- my $self = shift;
-
- my @doms = grep { $_->get_name =~ /^tck/ } $self->{conn}->list_domains;
- if (@doms) {
- die "there is/are " . int(@doms) . " pre-existing active domain(s) in this driver";
- }
-
- @doms = grep { $_->get_name =~ /^tck/ } $self->{conn}->list_defined_domains;
- if (@doms) {
- die "there is/are " . int(@doms) . " pre-existing inactive domain(s) in this driver";
- }
-
- my @pools = grep { $_->get_name =~ /^tck/ } $self->{conn}->list_storage_pools;
- if (@pools) {
- die "there is/are " . int(@pools) . " pre-existing active storage_pool(s) in this driver";
- }
-
- @pools = grep { $_->get_name =~ /^tck/ } $self->{conn}->list_defined_storage_pools;
- if (@pools) {
- die "there is/are " . int(@pools) . " pre-existing inactive storage_pool(s) in this driver";
- }
-}
-
-sub reset {
- my $self = shift;
-
- my @doms = grep { $_->get_name =~ /^tck/ } $self->{conn}->list_domains;
- foreach my $dom (@doms) {
- if ($dom->get_id != 0) {
- $dom->destroy;
- }
- }
-
- @doms = grep { $_->get_name =~ /^tck/ } $self->{conn}->list_defined_domains();
- foreach my $dom (@doms) {
- $dom->undefine;
- }
-
- my @pools = grep { $_->get_name =~ /^tck/ } $self->{conn}->list_storage_pools;
- foreach my $pool (@pools) {
- my @vols = $pool->list_volumes;
- foreach my $vol (@vols) {
- eval { $vol->delete(0) };
- }
- $pool->destroy;
- }
-
- @pools = grep { $_->get_name =~ /^tck/ } $self->{conn}->list_defined_storage_pools();
- foreach my $pool (@pools) {
- eval {
- $pool->delete(0);
- };
- $pool->undefine;
- }
-}
-
-sub cleanup {
- my $self = shift;
-
- $self->reset();
-
- delete $self->{conn};
-}
-
-sub config {
- my $self = shift;
- my $key = shift;
- if (@_) {
- my $default = shift;
- return $self->{config}->get($key, $default);
- } else {
- return $self->{config}->get($key);
- }
-}
-
-
-sub conn {
- my $self = shift;
- return $self->{conn};
-}
-
-
-sub scratch_dir {
- my $self = shift;
-
- my $scratch = $self->config("scratch_dir", $< > 0 ?
- catdir(cwd(), "libvirt-tck") :
- catdir(rootdir(), "var", "cache", "libvirt-tck"));
-
- mkpath($scratch) unless -e $scratch;
-
- return $scratch;
-}
-
-sub bucket_dir {
- my $self = shift;
- my $name = shift;
-
- my $scratch = $self->scratch_dir;
-
- my $bucket = catdir($scratch, $name);
- mkpath($bucket) unless -e $bucket;
-
- return $bucket;
-}
-
-sub get_scratch_resource {
- my $self = shift;
- my $source = shift;
- my $bucket = shift;
- my $name = shift;
-
- my $dir = $self->bucket_dir($bucket);
- my $target = catfile($dir, $name);
-
- return $target if -e $target;
-
- my $uncompress = undef;
- if (ref($source)) {
- $uncompress = $source->{uncompress};
- $source = $source->{source};
- }
-
- if ($source =~ m,^/,) {
- $self->copy_scratch($source, $target, $uncompress);
- } else {
- $self->download_scratch($source, $target, $uncompress);
- }
-
- return $target;
-}
-
-
-sub download_scratch {
- my $self = shift;
- my $source = shift;
- my $target = shift;
- my $uncompress = shift;
-
- my $ua = LWP::UserAgent->new;
- $ua->timeout(10);
- $ua->env_proxy;
-
- my $response = $ua->get($source);
-
- if ($response->is_success) {
- open TGT, ">$target" or die "cannot create $target: $!";
- if (defined $uncompress) {
- my $data = $response->content;
- if ($uncompress eq "gzip") {
- gunzip \$data => \*TGT;
- } elsif ($uncompress eq "bzip2") {
- bunzip2 \$data => \*TGT;
- } else {
- die "unknown compression method '$uncompress'";
- }
- } else {
- print TGT $response->content or die "cannot write $target: $!";
- }
- close TGT or die "cannot save $target: $!";
- } else {
- die "cannot download $source: " . $response->status_line;
- }
-
-}
-
-sub copy_scratch {
- my $self = shift;
- my $source = shift;
- my $target = shift;
- my $uncompress = shift;
-
- if (defined $uncompress) {
- if ($uncompress eq "gzip") {
- gunzip $source => $target;
- } elsif ($uncompress eq "bzip2") {
- bunzip2 $source => $target;
- } else {
- die "unknown compression method '$uncompress'";
- }
- } else {
- copy ($source, $target) or die "cannot copy $source to $target: $!";
- }
-}
-
-
-sub create_sparse_disk {
- my $self = shift;
- my $bucket = shift;
- my $name = shift;
- my $size = shift;
-
- my $dir = $self->bucket_dir($bucket);
-
- my $target = catfile($dir, $name);
-
- open DISK, ">$target" or die "cannot create $target: $!";
-
- truncate DISK, ($size * 1024 * 1024);
-
- close DISK or die "cannot save $target: $!";
-
- return $target;
-}
-
-
-sub create_minimal_vroot {
- my $self = shift;
- my $bucket = shift;
- my $name = shift;
-
- my $dir = $self->bucket_dir($bucket);
- my $target = catdir($dir, $name);
-
- mkpath($target) unless -e $target;
-
- my $busybox = $self->config("busybox", "/sbin/busybox");
-
- die "$busybox does not exist" unless $busybox;
-
- my $type = `file $busybox 2>&1`;
-
- die "$busybox is not statically linked" unless $type =~ /statically/;
-
- my @dirs = qw(sbin bin dev proc sys tmp);
-
- foreach my $dir (@dirs) {
- my $fulldir = catdir($target, $dir);
- next if -e $fulldir;
- mkpath($fulldir);
- }
-
- my $dst = catfile($target, "sbin", "busybox");
- copy ($busybox, $dst) or die "cannot copy $busybox to $dst: $!";
- chmod 0755, $dst or die "cannot make $dst executable: $!";
-
- my @links = qw(
- ed kill ping6 svlogd
- egrep killall pipe_progress swapoff
-addgroup eject killall5 pivot_root swapon
-adduser env klogd pkill switch_root
-adjtimex envdir last poweroff sync
-ar envuidgid length printenv sysctl
-arp expand less printf syslogd
-arping expr linux32 ps tail
-ash fakeidentd linux64 pscan tar
-awk false linuxrc pwd tcpsvd
-basename fbset ln raidautorun tee
-bunzip2 fdformat loadfont rdate telnet
-busybox fdisk loadkmap readahead telnetd
-bzcat fgrep logger readlink test
-bzip2 find login readprofile tftp
-cal fold logname realpath time
-cat free logread reboot top
-catv freeramdisk losetup renice touch
-chattr fsck ls reset tr
-chgrp fsck.minix lsattr resize traceroute
-chmod ftpget lsmod rm true
-chown ftpput lzmacat rmdir tty
-chpasswd fuser makedevs rmmod ttysize
-chpst getopt md5sum route udhcpc
-chroot getty mdev rpm udhcpd
-chrt grep mesg rpm2cpio udpsvd
-chvt gunzip microcom runlevel umount
-cksum gzip mkdir run-parts uname
-clear halt mkfifo runsv uncompress
-cmp hdparm mkfs.minix runsvdir unexpand
-comm head mknod rx uniq
-cp hexdump mkswap sed unix2dos
-cpio hostid mktemp seq unlzma
-crond hostname modprobe setarch unzip
-crontab httpd more setconsole uptime
-cryptpw hwclock mount setkeycodes usleep
-cut id mountpoint setlogcons uudecode
-date ifconfig msh setsid uuencode
-dc ifdown mt setuidgid vconfig
-dd ifup mv sh vi
-deallocvt inetd nameif sha1sum vlock
-delgroup init nc slattach watch
-deluser insmod netstat sleep watchdog
-df install nice softlimit wc
-dhcprelay ip nmeter sort wget
-diff ipaddr nohup split which
-dirname ipcalc nslookup start-stop-daemon who
-dmesg ipcrm od stat whoami
-dnsd ipcs openvt strings xargs
-dos2unix iplink passwd stty yes
-du iproute patch su zcat
-dumpkmap iprule pgrep sulogin zcip
-dumpleases iptunnel pidof sum
-echo kbd_mode ping sv);
-
- foreach my $file (@links) {
- my $fullfile = catfile($target, "bin", $file);
- next if -e $fullfile;
- symlink "../sbin/busybox", $fullfile
- or die "cannot symlink $fullfile to ../sbin/busybox: $!";
- }
-
- my $init = catfile($target, "sbin", "init");
- open INIT, ">$init" or die "cannot create $init: $!";
-
- print INIT <<EOF;
-#!/sbin/busybox
-
-sh
-EOF
-
- close INIT or die "cannot save $init: $!";
- chmod 0755, $init or die "cannot make $init executable: $!";
-
- return ($target, catfile(rootdir, "sbin", "init"));
-}
-
-sub match_kernel {
- my $self = shift;
- my $caps = shift;
- my $arch = shift;
- my $ostype = shift;
-
- for (my $i = 0 ; $i < $caps->num_guests ; $i++) {
- if ($caps->guest_os_type($i) eq $ostype &&
- $caps->guest_arch_name($i) eq $arch) {
-
- my @domains = $caps->guest_domain_types($i);
- next unless int(@domains);
-
- return ($domains[0],
- $caps->guest_domain_emulator($i, $domains[0]),
- $caps->guest_domain_loader($i, $domains[0]));
- }
- }
-
- return ();
-}
-
-
-sub best_kernel {
- my $self = shift;
- my $caps = shift;
-
- my $kernels = $self->config("kernels", []);
-
- for (my $i = 0 ; $i <= $#{$kernels} ; $i++) {
- my $arch = $kernels->[$i]->{arch};
- my $ostype = $kernels->[$i]->{ostype};
- my @ostype = ref($ostype) ? @{$ostype} : ($ostype);
-
- foreach $ostype (@ostype) {
- my ($domain, $emulator, $loader) =
- $self->match_kernel($caps, $arch, $ostype);
-
- if (defined $domain) {
- return ($i, $domain, $arch, $ostype, $emulator, $loader)
- }
- }
- }
-
- return ();
-}
-
-sub get_kernel {
- my $self = shift;
- my $caps = shift;
-
- my ($cfgindex, $domain, $arch, $ostype, $emulator, $loader) =
- $self->best_kernel($caps);
-
- if (!defined $cfgindex) {
- die "cannot find any supported kernel configuration";
- }
-
- my $kernels = $self->config("kernels", []);
-
- my $kernel = $kernels->[$cfgindex]->{kernel};
- my $initrd = $kernels->[$cfgindex]->{initrd};
- my $disk = $kernels->[$cfgindex]->{disk};
-
- my $bucket = "os-$arch-$ostype";
-
- my $kfile = $self->get_scratch_resource($kernel, $bucket, "vmlinuz");
- my $ifile = $initrd ? $self->get_scratch_resource($initrd, $bucket, "initrd") : undef;
- my $dfile = $disk ? $self->get_scratch_resource($disk, $bucket, "disk.img") : undef;
-
- unless (defined $dfile) {
- $dfile = $self->create_sparse_disk($bucket, "disk.img", 100);
- }
-
- chmod 0755, $kfile;
-
- my $dev;
- if ($ostype eq "xen") {
- $dev = "xvda";
- } elsif ($ostype eq "uml") {
- $dev = "ubda";
- } elsif ($ostype eq "hvm") {
- if ($domain eq "kvm" ||
- $domain eq "qemu" ||
- $domain eq "kqemu") {
- $dev = "vda";
- } else {
- $dev = "hda";
- }
- }
-
- return (
- domain => $domain,
- arch => $arch,
- ostype => $ostype,
- emulator => $emulator,
- loader => $loader,
- kernel => $kfile,
- initrd => $ifile,
- root => $dfile,
- dev => $dev,
- );
-}
-
-
-
-sub generic_machine_domain {
- my $self = shift;
- my $name = shift;
- my $caps = shift;
-
- my %config = $self->get_kernel($caps);
-
- my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $self->{conn},
- name => $name,
- domain => $config{domain},
- ostype => $config{ostype});
- $b->memory(64 * 1024);
- $b->with_acpi();
- $b->with_apic();
-
- # XXX boot CDROM or vroot for other HVs
- $b->boot_kernel($config{kernel}, $config{initrd});
-
- $b->disk(src => $config{root},
- dst => $config{dev},
- type => "file");
-
- return $b;
-}
-
-
-sub best_container_domain {
- my $self = shift;
- my $caps = shift;
-
- for (my $i = 0 ; $i < $caps->num_guests ; $i++) {
- if ($caps->guest_os_type($i) eq "exe") {
- my @domains = $caps->guest_domain_types($i);
- next unless int(@domains);
-
- return $domains[0];
- }
- }
-
- return undef;
-
-}
-
-sub generic_container_domain {
- my $self = shift;
- my $name = shift;
- my $caps = shift;
- my $domain = shift;
-
- my $bucket = "os-exe";
-
- my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $self->{conn},
- name => $name,
- domain => $domain,
- ostype => "exe");
- $b->memory(64 * 1024);
-
- my ($root, $init) = $self->create_minimal_vroot($bucket, $name);
-
- $b->boot_init($init);
-
- $b->filesystem(src => $root,
- dst => "/",
- type => "mount");
-
- return $b;
-}
-
-
-sub generic_domain {
- my $self = shift;
- my $name = @_ ? shift : "tck";
-
- my $caps = Sys::Virt::TCK::Capabilities->new(xml => $self->conn->get_capabilities);
-
- my $container = $self->best_container_domain($caps);
-
- if ($container) {
- return $self->generic_container_domain($name, $caps, $container);
- } else {
- return $self->generic_machine_domain($name, $caps);
- }
-}
-
-sub generic_pool {
- my $self = shift;
- my $type = shift;
- my $name = @_ ? shift : "tck";
-
- my $bucket = $self->bucket_dir("storage-fs");
-
- my $b = Sys::Virt::TCK::StoragePoolBuilder->new(name => $name,
- type => $type);
-
- $b->target(catdir($bucket, $name));
-
- return $b;
-}
-
-
-sub generic_volume {
- my $self = shift;
- my $name = @_ ? shift : "tck";
- my $format = @_ ? shift :undef;
- my $capacity = @_ ? shift : 1024*1024*50;
-
- my $b = Sys::Virt::TCK::StorageVolBuilder->new(name => $name);
- $b->format($format) if $format;
- $b->capacity($capacity);
-
- return $b;
-}
-
-# Borrowed from Test::Exception
-
-sub _quiet_caller (;$) { ## no critic Prototypes
- my $height = $_[0];
- $height++;
- if( wantarray and !@_ ) {
- return (CORE::caller($height))[0..2];
- }
- else {
- return CORE::caller($height);
- }
- }
-
-sub _try_as_caller {
- my $coderef = shift;
-
- # local works here because Sub::Uplevel has already overridden caller
- local *CORE::GLOBAL::caller;
- { no warnings 'redefine'; *CORE::GLOBAL::caller = \&_quiet_caller; }
-
- my $ret = eval { uplevel 3, $coderef };
- return ($ret, $@);
-};
-
-
-my $Tester = Test::Builder->new;
-
-sub ok_domain(&$;$) {
- my $coderef = shift;
- my $description = shift;
- my $name = shift;
-
- die "must pass coderef, description and (optional) expected name"
- unless defined $description;
-
- my ($ret, $exception) = _try_as_caller($coderef);
-
- my $ok = "$exception" eq "" &&
- $ret && ref($ret) && $ret->isa("Sys::Virt::Domain") &&
- (!defined $name || ($ret->get_name() eq $name));
-
- $Tester->ok($ok, $description);
- unless ($ok) {
- $Tester->diag("expected Sys::Virt::Domain object" . ($name ? " with name $name" : ""));
- if ($exception) {
- $Tester->diag("found '$exception'");
- } else {
- if ($ret && ref($ret) && $ret->isa("Sys::Virt::Domain")) {
- $Tester->diag("found Sys::Virt::Domain object with name " . $ret->get_name);
- } else {
- $Tester->diag("found '$ret'");
- }
- }
- }
-}
-
-sub ok_pool(&$;$) {
- my $coderef = shift;
- my $description = shift;
- my $name = shift;
-
- die "must pass coderef, description and (optional) expected name"
- unless defined $description;
-
- my ($ret, $exception) = _try_as_caller($coderef);
-
- my $ok = "$exception" eq "" &&
- $ret && ref($ret) && $ret->isa("Sys::Virt::StoragePool") &&
- (!defined $name || ($ret->get_name() eq $name));
-
- $Tester->ok($ok, $description);
- unless ($ok) {
- $Tester->diag("expected Sys::Virt::StoragePool object" . ($name ? " with name $name" : ""));
- if ($exception) {
- $Tester->diag("found '$exception'");
- } else {
- if ($ret && ref($ret) && $ret->isa("Sys::Virt::StoragePool")) {
- $Tester->diag("found Sys::Virt::StoragePool object with name " . $ret->get_name);
- } else {
- $Tester->diag("found '$ret'");
- }
- }
- }
-}
-
-sub ok_volume(&$;$) {
- my $coderef = shift;
- my $description = shift;
- my $name = shift;
-
- die "must pass coderef, description and (optional) expected name"
- unless defined $description;
-
- my ($ret, $exception) = _try_as_caller($coderef);
-
- my $ok = "$exception" eq "" &&
- $ret && ref($ret) && $ret->isa("Sys::Virt::StorageVol") &&
- (!defined $name || ($ret->get_name() eq $name));
-
- $Tester->ok($ok, $description);
- unless ($ok) {
- $Tester->diag("expected Sys::Virt::StorageVol object" . ($name ? " with name $name" : ""));
- if ($exception) {
- $Tester->diag("found '$exception'");
- } else {
- if ($ret && ref($ret) && $ret->isa("Sys::Virt::StorageVol")) {
- $Tester->diag("found Sys::Virt::StorageVol object with name " . $ret->get_name);
- } else {
- $Tester->diag("found '$ret'");
- }
- }
- }
-}
-
-sub ok_error(&$;$) {
- my $coderef = shift;
- my $description = shift;
- my $code = shift;
-
- die "must pass coderef, description and (optional) expected error code"
- unless defined $description;
-
- my ($ret, $exception) = _try_as_caller($coderef);
-
- my $ok = ref($exception) && $exception->isa("Sys::Virt::Error") &&
- (!defined $code || ($exception->code() == $code));
-
- $Tester->ok($ok, $description);
- unless ($ok) {
- $Tester->diag("expecting Sys::Virt::Error object" . ($code ? " with code $code" : ""));
- $Tester->diag("found '$exception'");
- }
- $@ = $exception;
- return $ok;
-}
-
-
-sub err_not_implemented {
- my $exception = shift;
-
- if ($exception &&
- ref($exception) &&
- $exception->isa("Sys::Virt::Error") &&
- $exception->code() == 3) {
- return 1;
- }
- return 0;
-}
-
-sub xpath {
- my $object = shift;
- my $path = shift;
-
- my $xml = $object->get_xml_description;
-
- my $xp = XML::XPath->new(xml => $xml);
-
- return $xp->find($path);
-}
-
-1;
--
1.6.6.1
14 years, 7 months
[libvirt] BUG: attaching - detaching network device only works 7 times
by Stefan Berger
With the current tip: While extending a test case I found that attaching
and detaching the following network device works only 7 times with the
below script:
<interface type='bridge'>
<source bridge='static'/>
<mac address='52:54:00:4d:a2:58'/>
<target dev='attach0'/>
</interface>
let c=1; while test 1; do virsh attach-device acl attach.xml ; virsh
detach-device acl attach.xml; echo ${c}; let c=c+1; done
Then the following error occurs:
error: Failed to attach device from attach.xml
error: operation failed: parsing pci_add reply failed: Too Many NICs
failed to add macaddr=52:54:00:4d:a2:58,vlan=1,name=net1
It looks like the detachment of the device is not done by qemu?
Regards,
Stefan
14 years, 7 months
[libvirt] Build failure on Ubuntu 9.10
by Chris Lalancette
Hey Jamie,
I've starting doing some automated builds of libvirt, and I've run into this
build failure on Ubuntu 9.10 (both for i386 and x86_64):
Git head revision: cffe619bdf9943282cc9f6a0cf815ad9f0fe7fd7
make all-recursive
make[1]: Entering directory `/root/libvirt'
Making all in gnulib/lib
make[2]: Entering directory `/root/libvirt/gnulib/lib'
...
make all-am
make[3]: Entering directory `/root/libvirt/src'
...
CC libvirt_lxc-capabilities.o
CC libvirt_lxc-domain_conf.o
CC libvirt_lxc-cpu_conf.o
CC libvirt_lxc-nwfilter_params.o
CC virt_aa_helper-virt-aa-helper.o
make[3]: *** No rule to make target `../src/libvirt_conf.la', needed by `virt-aa-helper'. Stop.
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory `/root/libvirt/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/root/libvirt/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/libvirt'
make: *** [all] Error 2
(if you want the full build log, or build with V=1, let me know). Any thoughts?
--
Chris Lalancette
14 years, 7 months
[libvirt] [PATCH] Fix apibuild.py warnings about missing ':'
by Matthias Bolte
---
I just pushed this trivial fix.
src/libvirt.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index d1b7880..ff36681 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -12616,7 +12616,7 @@ error:
}
/**
- * virDomainRevertToSnapshot
+ * virDomainRevertToSnapshot:
* @snapshot: a domain snapshot object
* @flags: unused flag parameters; callers should pass 0
*
@@ -12657,7 +12657,7 @@ error:
}
/**
- * virDomainSnapshotDelete
+ * virDomainSnapshotDelete:
* @snapshot: a domain snapshot object
* @flags: flag parameters
*
--
1.6.3.3
14 years, 7 months
[libvirt] [PATCH] nwfilter: fix tear down order and consolidate functions
by Stefan Berger
To avoid race-conditions, the tear down of a filter has to happen before
the tap interface disappears and another tap interface with the same
name can re-appear. This patch tries to fix this. In one place, where
communication with the qemu monitor may fail, I am only tearing the
filters down after knowing that the function did not fail.
I am also moving the tear down functions into an include file for other
drivers to reuse.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/nwfilter/nwfilter_gentech_driver.h | 14 ++++++++++++++
src/qemu/qemu_conf.c | 13 ++++++++-----
src/qemu/qemu_driver.c | 28 +++++++---------------------
3 files changed, 29 insertions(+), 26 deletions(-)
Index: libvirt-acl/src/qemu/qemu_conf.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_conf.c
+++ libvirt-acl/src/qemu/qemu_conf.c
@@ -4074,10 +4074,13 @@ int qemudBuildCommandLine(virConnectPtr
goto error;
if (VIR_REALLOC_N(*tapfds, (*ntapfds)+1) < 0) {
+ virNWFilterTearNWFilter(net);
close(tapfd);
goto no_memory;
}
+ last_good_net = i;
+
(*tapfds)[(*ntapfds)++] = tapfd;
if (snprintf(tapfd_name, sizeof(tapfd_name), "%d", tapfd) >= sizeof(tapfd_name))
@@ -4091,10 +4094,13 @@ int qemudBuildCommandLine(virConnectPtr
goto error;
if (VIR_REALLOC_N(*tapfds, (*ntapfds)+1) < 0) {
+ virNWFilterTearNWFilter(net);
close(tapfd);
goto no_memory;
}
+ last_good_net = i;
+
(*tapfds)[(*ntapfds)++] = tapfd;
if (snprintf(tapfd_name, sizeof(tapfd_name), "%d", tapfd) >= sizeof(tapfd_name))
@@ -4154,7 +4160,6 @@ int qemudBuildCommandLine(virConnectPtr
goto error;
ADD_ARG(host);
}
- last_good_net = i;
}
}
@@ -4603,6 +4608,8 @@ int qemudBuildCommandLine(virConnectPtr
no_memory:
virReportOOMError();
error:
+ for (i = 0; i <= last_good_net; i++)
+ virNWFilterTearNWFilter(def->nets[i]);
if (tapfds &&
*tapfds) {
for (i = 0; i < *ntapfds; i++)
@@ -4620,11 +4627,6 @@ int qemudBuildCommandLine(virConnectPtr
VIR_FREE((qenv)[i]);
VIR_FREE(qenv);
}
- for (i = 0; i <= last_good_net; i++) {
- virDomainNetDefPtr net = def->nets[i];
- if ((net->filter) && (net->ifname))
- virNWFilterTeardownFilter(net);
- }
return -1;
#undef ADD_ARG
Index: libvirt-acl/src/qemu/qemu_driver.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_driver.c
+++ libvirt-acl/src/qemu/qemu_driver.c
@@ -3070,21 +3070,6 @@ cleanup:
}
-static void
-qemuTearNWFilter(virDomainNetDefPtr net) {
- if ((net->filter) && (net->ifname))
- virNWFilterTeardownFilter(net);
-}
-
-
-static void
-qemuTearVMNWFilters(virDomainObjPtr vm) {
- int i;
- for (i = 0; i < vm->def->nnets; i++)
- qemuTearNWFilter(vm->def->nets[i]);
-}
-
-
struct qemudHookData {
virConnectPtr conn;
virDomainObjPtr vm;
@@ -3397,6 +3382,9 @@ static int qemudStartVMDaemon(virConnect
VIR_FREE(progenv[i]);
VIR_FREE(progenv);
+ if (ret == -1) /* The VM failed to start; tear filters before taps */
+ virNWFilterTearVMNWFilters(vm);
+
if (tapfds) {
for (i = 0 ; i < ntapfds ; i++) {
close(tapfds[i]);
@@ -3461,8 +3449,6 @@ cleanup:
/* We jump here if we failed to start the VM for any reason
* XXX investigate if we can kill this block and safely call
* qemudShutdownVMDaemon even though no PID is running */
- qemuTearVMNWFilters(vm);
-
qemuDomainReAttachHostDevices(driver, vm->def);
if (driver->securityDriver &&
@@ -3511,7 +3497,7 @@ static void qemudShutdownVMDaemon(struct
* reporting so we don't squash a legit error. */
orig_err = virSaveLastError();
- qemuTearVMNWFilters(vm);
+ virNWFilterTearVMNWFilters(vm);
if (driver->macFilter) {
def = vm->def;
@@ -7153,7 +7139,8 @@ cleanup:
qemuDomainPCIAddressReleaseAddr(priv->pciaddrs, &net->info) < 0)
VIR_WARN0("Unable to release PCI address on NIC");
- qemuTearNWFilter(net);
+ if (ret != 0)
+ virNWFilterTearNWFilter(net);
VIR_FREE(nicstr);
VIR_FREE(netstr);
@@ -7953,6 +7940,8 @@ qemudDomainDetachNetDevice(struct qemud_
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
+ virNWFilterTearNWFilter(detach);
+
#if WITH_MACVTAP
if (detach->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
if (detach->ifname)
@@ -7970,8 +7959,6 @@ qemudDomainDetachNetDevice(struct qemud_
}
}
- qemuTearNWFilter(detach);
-
if (vm->def->nnets > 1) {
memmove(vm->def->nets + i,
vm->def->nets + i + 1,
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.h
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
@@ -65,4 +65,20 @@ void virNWFilterDomainFWUpdateCB(void *p
const char *name ATTRIBUTE_UNUSED,
void *data);
+
+/* tear down an interface's filter before tearing down the interface */
+static inline void
+virNWFilterTearNWFilter(virDomainNetDefPtr net) {
+ if ((net->filter) && (net->ifname))
+ virNWFilterTeardownFilter(net);
+}
+
+
+static inline void
+virNWFilterTearVMNWFilters(virDomainObjPtr vm) {
+ int i;
+ for (i = 0; i < vm->def->nnets; i++)
+ virNWFilterTearNWFilter(vm->def->nets[i]);
+}
+
#endif
14 years, 7 months
[libvirt] with these, clang vs. libvirt reports no errors
by Jim Meyering
I've been running clang regularly, and there have been a few
pesky false-positives that just won't go away.
It's not productive to reexamine them each time, so I've wanted
a way to educate clang without polluting the code with work-arounds
that we'll be stuck maintaining and asking questions about long
after clang becomes smart enough that those work-arounds are no
longer required.
My solution is to mark the work-arounds with a new macro, sa_assert
(for "static analysis assert"), which acts just like the classical
"assert", but is only enabled when compiled by a static analyzer
like clang or coverity. The advantage of using an assert-like
macro is that people already know that it must have no side-effects
and that will make it easy to remove later, when clang grows up.
One question you may ask is why add a new symbol, when
"assert" itself can already do this via NDEBUG (defined, any
assertions are disabled, not defined, they are enabled).
There are a few assertions in the code now, and I prefer
not to touch them, and to make it clear that these are
helping us cater to static analyzers.
[PATCH 1/7] sa_assert: new assert-like macro, enabled only for use with static analyzers
[PATCH 2/7] build: set STATIC_ANALYSIS when running via clang or coverity
[PATCH 3/7] nwfilter_ebiptables_driver.c: avoid NULL dereference
[PATCH 4/7] virGetHostnameLocalhost: avoid FP NULL-ptr-deref from clang
[PATCH 5/7] qemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang
[PATCH 6/7] xend_internal.c: assure clang that we do not dereference NULL
[PATCH 7/7] qemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang
14 years, 7 months
[libvirt] [PATCH] Add testing for CDROM media change / eject
by Daniel P. Berrange
This tests the 3 main operations in removeable media
- Eject existing media
- Insert new media
- Change existing media (eject followed by insert)
* lib/Sys/Virt/TCK.pm: Allow a specific ostype to be requested
when getting a guest config
* scripts/domain/207-disk-media-change.t: Test media change,
eject, and re-insert
---
lib/Sys/Virt/TCK.pm | 20 +++++-
scripts/domain/207-disk-media-change.t | 95 ++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+), 4 deletions(-)
create mode 100644 scripts/domain/207-disk-media-change.t
diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
index d32b03d..9f67c08 100644
--- a/lib/Sys/Virt/TCK.pm
+++ b/lib/Sys/Virt/TCK.pm
@@ -416,6 +416,7 @@ sub match_kernel {
sub best_kernel {
my $self = shift;
my $caps = shift;
+ my $wantostype = shift;
my $kernels = $self->config("kernels", []);
@@ -425,6 +426,11 @@ sub best_kernel {
my @ostype = ref($ostype) ? @{$ostype} : ($ostype);
foreach $ostype (@ostype) {
+ if ((defined $wantostype) &&
+ ($wantostype ne $ostype)) {
+ next;
+ }
+
my ($domain, $emulator, $loader) =
$self->match_kernel($caps, $arch, $ostype);
@@ -440,9 +446,10 @@ sub best_kernel {
sub get_kernel {
my $self = shift;
my $caps = shift;
+ my $wantostype = shift;
my ($cfgindex, $domain, $arch, $ostype, $emulator, $loader) =
- $self->best_kernel($caps);
+ $self->best_kernel($caps, $wantostype);
if (!defined $cfgindex) {
die "cannot find any supported kernel configuration";
@@ -500,8 +507,9 @@ sub generic_machine_domain {
my $self = shift;
my $name = shift;
my $caps = shift;
+ my $ostype = shift;
- my %config = $self->get_kernel($caps);
+ my %config = $self->get_kernel($caps, $ostype);
my $b = Sys::Virt::TCK::DomainBuilder->new(conn => $self->{conn},
name => $name,
@@ -568,15 +576,19 @@ sub generic_container_domain {
sub generic_domain {
my $self = shift;
my $name = @_ ? shift : "tck";
+ my $ostype = @_ ? shift : undef;
my $caps = Sys::Virt::TCK::Capabilities->new(xml => $self->conn->get_capabilities);
- my $container = $self->best_container_domain($caps);
+ my $container;
+
+ $container = $self->best_container_domain($caps)
+ unless $ostype && $ostype ne "exe";
if ($container) {
return $self->generic_container_domain($name, $caps, $container);
} else {
- return $self->generic_machine_domain($name, $caps);
+ return $self->generic_machine_domain($name, $caps, $ostype);
}
}
diff --git a/scripts/domain/207-disk-media-change.t b/scripts/domain/207-disk-media-change.t
new file mode 100644
index 0000000..2976800
--- /dev/null
+++ b/scripts/domain/207-disk-media-change.t
@@ -0,0 +1,95 @@
+# -*- perl -*-
+#
+# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009 Daniel P. Berrange
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+domain/207-disk-media-change.t - verify disk media change works
+
+=head1 DESCRIPTION
+
+The test case validates that it is possible to change media
+on a CDROM disk in a running domain.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 7;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+ $tck->cleanup if $tck;
+}
+
+my $path1 = $tck->create_sparse_disk("200-disk-media-change", "extra1.img", 100);
+my $path2 = $tck->create_sparse_disk("207-disk-media-change", "extra2.img", 100);
+
+my $xml = $tck->generic_domain("tck", "wibble")
+ ->disk(src => $path1, dst => "hdc", type => "file", device => "cdrom")
+ ->as_xml;
+
+diag "Creating a new transient domain";
+my $dom;
+ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
+
+
+my $diskxml1 = <<EOF;
+<disk type='file' device='cdrom'>
+ <source file='$path1'/>
+ <target dev='hdc'/>
+</disk>
+EOF
+my $diskxml2 = <<EOF;
+<disk type='file' device='cdrom'>
+ <source file='$path2'/>
+ <target dev='hdc'/>
+</disk>
+EOF
+my $diskxml3 = <<EOF;
+<disk type='file' device='cdrom'>
+ <target dev='hdc'/>
+</disk>
+EOF
+
+
+my $initialxml = $dom->get_xml_description;
+
+diag "Changing CDROM to $path2";
+lives_ok(sub { $dom->attach_device($diskxml2); }, "disk media has been changed");
+
+my $newxml = $dom->get_xml_description;
+
+ok($newxml =~ m|$path2|, "new XML has updated media");
+
+diag "Ejecting CDROM media";
+lives_ok(sub { $dom->attach_device($diskxml3); }, "disk media has been ejected");
+
+$newxml = $dom->get_xml_description;
+
+ok($newxml !~ m|$path2|, "new XML has no media");
+
+diag "Inserting CDROM media";
+lives_ok(sub { $dom->attach_device($diskxml1); }, "disk media has been inserted");
+
+my $finalxml = $dom->get_xml_description;
+
+is($initialxml, $finalxml, "final XML matches initial XML");
--
1.6.6.1
14 years, 7 months
[libvirt] [PATCH] Fix close_used_without_including_unistd_h error
by Matthias Bolte
Triggered by gnulib when compiling with MinGW.
---
I just pushed this trivial compile fix too.
src/conf/nwfilter_conf.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index f4af126..336ea3b 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -33,6 +33,7 @@
#if HAVE_NET_ETHERNET_H
# include <net/ethernet.h>
#endif
+#include <unistd.h>
#include "internal.h"
--
1.6.3.3
14 years, 7 months
[libvirt] [PATCH 0/1] Variable length structure allocator
by David Allan
I've had this patch hanging around for a while, and I think it's worth committing even though the original reason for it went away. The kind of structure it allocates is reasonably common, and the oversize calculation is tricky to get right. Since we've already done the work (thanks Jim for the oversize calculation) I think it's worth keeping.
Dave
David Allan (1):
Implement variable length structure allocator
src/util/memory.c | 40 ++++++++++++++++++++++++++++++++++++++++
src/util/memory.h | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+), 0 deletions(-)
14 years, 7 months