[libvirt] [libvirt-tck][PATCH] Add two APIs testing for metadata

2015-03-05 Thread Zhe Peng
$dom-set_metadata
$dom-get_metadata
only have title and destription
element not support in libvirt now

Signed-off-by: Zhe Peng zp...@redhat.com
---
 scripts/domain/500-metadata.t | 72 +++
 1 file changed, 72 insertions(+)
 create mode 100644 scripts/domain/500-metadata.t

diff --git a/scripts/domain/500-metadata.t b/scripts/domain/500-metadata.t
new file mode 100644
index 000..11f2f6d
--- /dev/null
+++ b/scripts/domain/500-metadata.t
@@ -0,0 +1,72 @@
+# -*- perl -*-
+#
+# Copyright (C) 2014 Red Hat, Inc.
+# Copyright (C) 2014 Zhe Peng
+#
+# 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/500-metadata.t -- set/get metadata from guest.
+
+=head1 DESCRIPTION
+
+The test case validates that libvirt can set/get guest metadata
+Sys::Virt::Domain::METADATA_TITLE
+Sys::Virt::Domain::METADATA_DESCRIPTION
+not support Sys::Virt::Domain::METADATA_ELEMENT
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 8;
+
+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 $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);
+
+my $title = libvirt tck testing title;
+my $des = perl-Sys-Virt description;
+
+lives_ok(sub {$dom-set_metadata(Sys::Virt::Domain::METADATA_TITLE, $title, 
undef, undef, 0)}, Set title to $title );
+lives_ok(sub {$dom-set_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION, 
$des, undef, undef, 0)}, Set description to $des );
+
+my $hasMetadata = $dom-get_xml_description;
+
+ok($hasMetadata =~ m|$title|, title has added in guest);
+ok($hasMetadata =~ m|$des|, description has added in guest);
+
+my $mTitle = $dom-get_metadata(Sys::Virt::Domain::METADATA_TITLE,undef,0);
+my $mDes = $dom-get_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,undef,0);
+
+is($mTitle, $title, Get title from guest);
+is($mDes, $des, Get description from guest);
+
+diag Destroy domain;
+$dom-destroy;
+
+ok_error(sub { $conn-get_domain_by_name(tck) }, NO_DOMAIN error raised 
from missing domain, 42);
+
-- 
1.9.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-tck][PATCH] This testcase tests if the open_graphics_fd function works properly.

2015-03-05 Thread Zhe Peng
Signed-off-by: Hao Liu h...@redhat.com
---
 scripts/domain/275-open-graphics-fd.t | 76 +++
 1 file changed, 76 insertions(+)
 create mode 100644 scripts/domain/275-open-graphics-fd.t

diff --git a/scripts/domain/275-open-graphics-fd.t 
b/scripts/domain/275-open-graphics-fd.t
new file mode 100644
index 000..9377f50
--- /dev/null
+++ b/scripts/domain/275-open-graphics-fd.t
@@ -0,0 +1,76 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012-2014 Red Hat, Inc.
+# Copyright (C) 2014 Hao Liu h...@redhat.com
+#
+# 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/275-open-graphics-fd.t - Test open_graphics_fd function
+
+=head1 DESCRIPTION
+
+The test case validates that open_graphics_fd function works well
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 9;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+use IO::Handle;
+
+my $tck = Sys::Virt::TCK-new();
+my $conn = eval { $tck-setup(); };
+BAIL_OUT failed to setup test harness: $@ if $@;
+END {
+$tck-cleanup if $tck;
+}
+
+
+# looking up domain
+my $dom_name =tck;
+my $xml = $tck-generic_domain(name = $dom_name)-as_xml;
+diag domain xml is $xml;
+my $dom = $conn-define_domain($xml);
+$dom-create;
+ok($dom-get_id()  0, running domain has an ID  0);
+my $graphics_cnt = xpath($dom, count(/domain/devices/graphics))-value();
+my $valid_idx = $graphics_cnt - 1;
+my $invalid_idx = $graphics_cnt;
+
+my $fd = 0;
+my $fh = IO::Handle-new();
+
+diag open fd for valid graphics device;
+lives_ok(sub {$fd = $dom-open_graphics_fd($valid_idx, 0)}, open graphics 
fd);
+ok($fd  0, graphic fd is $fd);
+$fh-fdopen($fd, r);
+ok($fh-opened, fd is accessible);
+$fh-close();
+
+diag open fd for valid graphics device skip auth;
+$fd = 0;
+lives_ok(sub {$fd = $dom-open_graphics_fd($valid_idx, 
Sys::Virt::Domain::OPEN_GRAPHICS_SKIPAUTH)}, open graphics fd);
+ok($fd  0, graphic fd is $fd);
+$fh-fdopen($fd, r);
+ok($fh-opened, fd is accessible);
+$fh-close();
+
+diag open fd for non-exist graphics device;
+$fd = 0;
+ok_error(sub {$fd = $dom-open_graphics_fd($invalid_idx, 0)}, open graphics 
fd);
+ok($fd eq 0, graphic fd is not returned);
-- 
1.9.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-tck][PATCH] Fix disk interface hot plug unplug test scripts

2015-03-05 Thread Zhe Peng
This patch fixed following issues:
1) Hot unplug won't work for a VM without OS. Create a working VM
   instead.
2) Avoid using multicast MAC address.

Signed-off-by: Zhe Peng zp...@redhat.com
---
 scripts/domain/200-disk-hotplug.t  | 5 +++--
 scripts/domain/205-disk-hotplug-ordering.t | 3 ++-
 scripts/domain/210-nic-hotplug.t   | 5 +++--
 scripts/domain/215-nic-hotplug-many.t  | 9 +
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/scripts/domain/200-disk-hotplug.t 
b/scripts/domain/200-disk-hotplug.t
index 4c54b6b..7ed5b27 100644
--- a/scripts/domain/200-disk-hotplug.t
+++ b/scripts/domain/200-disk-hotplug.t
@@ -41,13 +41,14 @@ END {
 }
 
 
-my $xml = $tck-generic_domain(name = tck)-as_xml;
+my $xml = $tck-generic_domain(name = tck, fullos = 1)-as_xml;
 
 diag Creating a new transient domain;
 my $dom;
 ok_domain(sub { $dom = $conn-create_domain($xml) }, created transient domain 
object);
 
 
+sleep(30);
 my $path = $tck-create_sparse_disk(200-disk-hotplug, extra.img, 100);
 
 my $dev = vdb;
@@ -76,4 +77,4 @@ lives_ok(sub { $dom-detach_device($diskxml); }, disk has 
been detached);
 
 my $finalxml = $dom-get_xml_description;
 
-is($initialxml, $finalxml, final XML has removed the disk)
+is($finalxml, $initialxml, final XML has removed the disk)
diff --git a/scripts/domain/205-disk-hotplug-ordering.t 
b/scripts/domain/205-disk-hotplug-ordering.t
index bc4990f..c9a300c 100644
--- a/scripts/domain/205-disk-hotplug-ordering.t
+++ b/scripts/domain/205-disk-hotplug-ordering.t
@@ -41,12 +41,13 @@ END {
 }
 
 
-my $xml = $tck-generic_domain(name = tck)-as_xml;
+my $xml = $tck-generic_domain(name = tck, fullos = 1)-as_xml;
 
 diag Creating a new transient domain;
 my $dom;
 ok_domain(sub { $dom = $conn-create_domain($xml) }, created transient domain 
object);
 
+sleep(30);
 my $supported = 1;
 foreach my $dev (qw/vdb sdb/) {
 my $path = $tck-create_sparse_disk(200-disk-hotplug, extra-$dev.img, 
100);
diff --git a/scripts/domain/210-nic-hotplug.t b/scripts/domain/210-nic-hotplug.t
index ac9048e..4a2763f 100644
--- a/scripts/domain/210-nic-hotplug.t
+++ b/scripts/domain/210-nic-hotplug.t
@@ -41,11 +41,12 @@ END {
 }
 
 
-my $xml = $tck-generic_domain(name = tck)-as_xml;
+my $xml = $tck-generic_domain(name = tck, fullos = 1)-as_xml;
 
 diag Creating a new transient domain;
 my $dom;
 ok_domain(sub { $dom = $conn-create_domain($xml) }, created transient domain 
object);
+sleep(30);
 
 my $mac = 00:11:22:33:44:55;
 my $model = virtio;
@@ -72,4 +73,4 @@ lives_ok(sub { $dom-detach_device($netxml); }, interface 
has been detached);
 
 my $finalxml = $dom-get_xml_description;
 
-is($initialxml, $finalxml, final XML has removed the disk)
+is($finalxml, $initialxml, final XML has removed the interface)
diff --git a/scripts/domain/215-nic-hotplug-many.t 
b/scripts/domain/215-nic-hotplug-many.t
index 0270054..d4fa23e 100644
--- a/scripts/domain/215-nic-hotplug-many.t
+++ b/scripts/domain/215-nic-hotplug-many.t
@@ -41,15 +41,16 @@ END {
 }
 
 
-my $xml = $tck-generic_domain(name = tck)-as_xml;
+my $xml = $tck-generic_domain(name = tck, fullos = 1)-as_xml;
 
 diag Creating a new transient domain;
 my $dom;
 ok_domain(sub { $dom = $conn-create_domain($xml) }, created transient domain 
object);
+sleep(30);
 
-my $mac1 = 01:11:22:33:44:55;
-my $mac2 = 02:11:22:33:44:55;
-my $mac3 = 03:11:22:33:44:55;
+my $mac1 = 02:11:22:33:44:55;
+my $mac2 = 04:11:22:33:44:55;
+my $mac3 = 06:11:22:33:44:55;
 my $model = virtio;
 
 my $netxml1 = EOF;
-- 
1.9.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-tck][PATCH] Add new api get_all_domain_stats testing

2015-03-05 Thread Zhe Peng
$vmm-get_all_domain_stats
Sys::Virt::GET_ALL_STATS_ACTIVE
Sys::Virt::GET_ALL_STATS_INACTIVE
Sys::Virt::GET_ALL_STATS_OTHER
Sys::Virt::GET_ALL_STATS_PAUSED
Sys::Virt::GET_ALL_STATS_PERSISTENT
Sys::Virt::GET_ALL_STATS_RUNNING
Sys::Virt::GET_ALL_STATS_SHUTOFF
Sys::Virt::GET_ALL_STATS_TRANSIENT
Sys::Virt::GET_ALL_STATS_ENFORCE_STATS

Signed-off-by: Zhe Peng zp...@redhat.com
---
 scripts/domain/800-get-all-stats.t | 137 +
 1 file changed, 137 insertions(+)
 create mode 100644 scripts/domain/800-get-all-stats.t

diff --git a/scripts/domain/800-get-all-stats.t 
b/scripts/domain/800-get-all-stats.t
new file mode 100644
index 000..4ff4bf3
--- /dev/null
+++ b/scripts/domain/800-get-all-stats.t
@@ -0,0 +1,137 @@
+# -*- perl -*-
+#
+# Copyright (C) 2014 Red Hat, Inc.
+# Copyright (C) 2014 Zhe Peng
+#
+# 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/800-get-all-stats.t
+
+=head1 DESCRIPTION
+
+The test case validates that:
+$vmm-get_all_domain_stats
+Sys::Virt::GET_ALL_STATS_ACTIVE
+Sys::Virt::GET_ALL_STATS_INACTIVE
+Sys::Virt::GET_ALL_STATS_OTHER
+Sys::Virt::GET_ALL_STATS_PAUSED
+Sys::Virt::GET_ALL_STATS_PERSISTENT
+Sys::Virt::GET_ALL_STATS_RUNNING
+Sys::Virt::GET_ALL_STATS_SHUTOFF
+Sys::Virt::GET_ALL_STATS_TRANSIENT
+Sys::Virt::GET_ALL_STATS_ENFORCE_STATS
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 11;
+
+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 @doms = (tck1, tck2, tck3, tck4);
+
+#create two persistent domain, tck1 and tck2
+
+my $xml = $tck-generic_domain(name = tck1)-as_xml;
+
+diag Defining an inactive domain config;
+
+my $dom1;
+
+ok_domain(sub { $dom1 = $conn-define_domain($xml) }, defined persistent 
domain config);
+
+my $xml2 = $tck-generic_domain(name = tck2)-as_xml;
+
+diag Defining an inactive domain config;
+
+my $dom2;
+
+ok_domain(sub { $dom2 = $conn-define_domain($xml2) }, defined persistent 
domain config);
+
+my $stats_persistent = 
Sys::Virt::Domain::GET_ALL_STATS_PERSISTENT|Sys::Virt::Domain::GET_ALL_STATS_INACTIVE;
+my @dom_persistent = 
$conn-get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, undef, 
$stats_persistent);
+
+is($#dom_persistent+1, 2, list all persistent domain);
+
+#create two transient domain, tck3 and tck4
+
+my $xml3 = $tck-generic_domain(name = tck3)-as_xml;
+
+diag Creating a new transient domain;
+my $dom3;
+ok_domain(sub { $dom3 = $conn-create_domain($xml3) }, created transient 
domain object);
+
+my $xml4 = $tck-generic_domain(name = tck4)-as_xml;
+
+diag Creating a new transient domain;
+my $dom4;
+ok_domain(sub { $dom4 = $conn-create_domain($xml4) }, created transient 
domain object);
+
+my $stats_transient = 
Sys::Virt::Domain::GET_ALL_STATS_TRANSIENT|Sys::Virt::Domain::GET_ALL_STATS_RUNNING;
+
+my @dom_transient = 
$conn-get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, undef, 
$stats_transient);
+
+is($#dom_transient+1, 2, list all transient domain);
+
+#start  pause persistent domain 2 and  one transient dom
+$dom2-create();
+$dom2-suspend();
+$dom3-suspend();
+
+my $stats_pause = Sys::Virt::Domain::GET_ALL_STATS_PAUSED;
+
+my @dom_pause = $conn-get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, 
undef, $stats_pause);
+
+is($#dom_pause+1, 2, list all pause domain);
+
+#resume dom2 and dom3
+$dom2-resume();
+$dom3-resume();
+
+my $stats_active = Sys::Virt::Domain::GET_ALL_STATS_ACTIVE;
+
+my@dom_active = $conn-get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, 
undef, $stats_active);
+
+is($#dom_active+1, 3, list all active domain);
+
+my $stats_shutoff = Sys::Virt::Domain::GET_ALL_STATS_SHUTOFF;
+
+my @dom_shutoff = $conn-get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, 
undef, $stats_shutoff);
+
+is($#dom_shutoff+1, 1, list all shutoff domain);
+
+my $stats_other = Sys::Virt::Domain::GET_ALL_STATS_OTHER;
+
+my @dom_other = $conn-get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, 
undef, $stats_other);
+
+is($#dom_other+1, 0, list all other domain);
+
+my $stats_enforce = Sys::Virt::Domain::GET_ALL_STATS_ENFORCE_STATS;
+
+my @dom_enforce = $conn-get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, 
undef, $stats_enforce);
+
+is($#dom_enforce+1, 4, list all enforce domain);
+
+
+
-- 
1.9.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-perl][PATCH] Fix constants for VIR_DOMAIN_GET_ALL_STATS_*

2014-12-03 Thread Zhe Peng
Constants of GET_ALL_STATS_* incorrect,this patch fix them in Domain.pm
---
 lib/Sys/Virt/Domain.pm | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm
index 5680afa..e5ce2dd 100644
--- a/lib/Sys/Virt/Domain.pm
+++ b/lib/Sys/Virt/Domain.pm
@@ -3287,39 +3287,39 @@ bulk domain stats from 
CSys::Virt::get_all_domain_stats.
 
 =over 4
 
-=item Sys::Virt::GET_ALL_STATS_ACTIVE
+=item Sys::Virt::Domain::GET_ALL_STATS_ACTIVE
 
 Include stats for active domains
 
-=item Sys::Virt::GET_ALL_STATS_INACTIVE
+=item Sys::Virt::Domain::GET_ALL_STATS_INACTIVE
 
 Include stats for inactive domains
 
-=item Sys::Virt::GET_ALL_STATS_OTHER
+=item Sys::Virt::Domain::GET_ALL_STATS_OTHER
 
 Include stats for other domains
 
-=item Sys::Virt::GET_ALL_STATS_PAUSED
+=item Sys::Virt::Domain::GET_ALL_STATS_PAUSED
 
 Include stats for paused domains
 
-=item Sys::Virt::GET_ALL_STATS_PERSISTENT
+=item Sys::Virt::Domain::GET_ALL_STATS_PERSISTENT
 
 Include stats for persistent domains
 
-=item Sys::Virt::GET_ALL_STATS_RUNNING
+=item Sys::Virt::Domain::GET_ALL_STATS_RUNNING
 
 Include stats for running domains
 
-=item Sys::Virt::GET_ALL_STATS_SHUTOFF
+=item Sys::Virt::Domain::GET_ALL_STATS_SHUTOFF
 
 Include stats for shutoff domains
 
-=item Sys::Virt::GET_ALL_STATS_TRANSIENT
+=item Sys::Virt::Domain::GET_ALL_STATS_TRANSIENT
 
 Include stats for transient domains
 
-=item Sys::Virt::GET_ALL_STATS_ENFORCE_STATS
+=item Sys::Virt::Domain::GET_ALL_STATS_ENFORCE_STATS
 
 Require that all requested stats fields are returned
 
-- 
1.9.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/3] qemu: Send migrate_cancel when aborting migration

2014-05-23 Thread Zhe Peng


- Original Message -
 From: Wangrui (K) moon.wang...@huawei.com
 To: Jiri Denemark jdene...@redhat.com, libvir-list@redhat.com
 Sent: Friday, May 23, 2014 9:40:23 AM
 Subject: Re: [libvirt] [PATCH 2/3] qemu: Send migrate_cancel when 
 abortingmigration
 
 
 
  -Original Message-
  From: libvir-list-boun...@redhat.com
  [mailto:libvir-list-boun...@redhat.com]
  On Behalf Of Jiri Denemark
  Sent: Thursday, May 22, 2014 7:55 PM
  To: libvir-list@redhat.com
  Subject: [libvirt] [PATCH 2/3] qemu: Send migrate_cancel when aborting
  migration
  
  When QEMU reports failed or cancelled migration, we don't need to send
  it migrate_cancel QMP command. But in all other error paths, such as if
  we detect broken connection to a destination daemon or something else
  happens inside libvirt, we need to explicitly send migrate_cancel
  command instead of relying on the migration to be implicitly cancelled
  when destination QEMU is killed.
  
  Because we were not doing so, one could end up with a paused domain
  after failed migration.
  
  https://bugzilla.redhat.com/show_bug.cgi?id=807023
 
 Hi, Jiri
 I'm interested in the patch. I want to know the specific scene.
 But the bug link you posted is about device_del. Is there another link about
 migration? (I think)

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

 
 
  Signed-off-by: Jiri Denemark jdene...@redhat.com
  ---
 
 
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list
 

-- 
Best Regards
Zhe Peng

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-sandbox][PATCH] Update man page about virt-sandbox-service

2013-08-07 Thread Zhe Peng
Add upgrade and remove start,stop,list
---
 bin/virt-sandbox-service.pod |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/bin/virt-sandbox-service.pod b/bin/virt-sandbox-service.pod
index 32caad9..e8ab55e 100644
--- a/bin/virt-sandbox-service.pod
+++ b/bin/virt-sandbox-service.pod
@@ -4,7 +4,7 @@ virt-sandbox-service - Secure container tool
 
 =head1 SYNOPSIS
 
-  {create,clone,connect,delete,execute,list,reload,start,stop}
+  {create,clone,connect,delete,execute,reload,upgrade}
 
   commands:
 
@@ -20,6 +20,8 @@ virt-sandbox-service - Secure container tool
 
 reload  Reload a running sandbox container
 
+upgrade Upgrade an existing Secure container
+
 =head1 DESCRIPTION
 
 virt-sandbox-service is used to provision secure sandboxed system services.
@@ -52,7 +54,7 @@ supported currently).
 
 =head1 SEE ALSO
 
-Clibvirt(8), Cselinux(8), Csystemd(8), Cvirt-sandbox(1), 
Cvirt-sandbox-service-create(1), Cvirt-sandbox-service-clone(1), 
Cvirt-sandbox-service-connect(1), Cvirt-sandbox-service-delete(1), 
Cvirt-sandbox-service-execute(1), Cvirt-sandbox-service-reload(1)
+Clibvirt(8), Cselinux(8), Csystemd(8), Cvirt-sandbox(1), 
Cvirt-sandbox-service-create(1), Cvirt-sandbox-service-clone(1), 
Cvirt-sandbox-service-connect(1), Cvirt-sandbox-service-delete(1), 
Cvirt-sandbox-service-execute(1), Cvirt-sandbox-service-reload(1), 
Cvirt-sandbox-service-upgrade(1)
 
 =head1 FILES
 
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-sandbox][PATCH v2] Update man page about virt-sandbox-service

2013-08-07 Thread Zhe Peng
Add upgrade and remove start,stop,list
---
 bin/virt-sandbox-service.pod |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/bin/virt-sandbox-service.pod b/bin/virt-sandbox-service.pod
index 32caad9..7752145 100644
--- a/bin/virt-sandbox-service.pod
+++ b/bin/virt-sandbox-service.pod
@@ -4,7 +4,7 @@ virt-sandbox-service - Secure container tool
 
 =head1 SYNOPSIS
 
-  {create,clone,connect,delete,execute,list,reload,start,stop}
+  {create,clone,connect,delete,execute,reload,upgrade}
 
   commands:
 
@@ -20,6 +20,8 @@ virt-sandbox-service - Secure container tool
 
 reload  Reload a running sandbox container
 
+upgrade Upgrade an existing sandbox container
+
 =head1 DESCRIPTION
 
 virt-sandbox-service is used to provision secure sandboxed system services.
@@ -52,7 +54,7 @@ supported currently).
 
 =head1 SEE ALSO
 
-Clibvirt(8), Cselinux(8), Csystemd(8), Cvirt-sandbox(1), 
Cvirt-sandbox-service-create(1), Cvirt-sandbox-service-clone(1), 
Cvirt-sandbox-service-connect(1), Cvirt-sandbox-service-delete(1), 
Cvirt-sandbox-service-execute(1), Cvirt-sandbox-service-reload(1)
+Clibvirt(8), Cselinux(8), Csystemd(8), Cvirt-sandbox(1), 
Cvirt-sandbox-service-create(1), Cvirt-sandbox-service-clone(1), 
Cvirt-sandbox-service-connect(1), Cvirt-sandbox-service-delete(1), 
Cvirt-sandbox-service-execute(1), Cvirt-sandbox-service-reload(1), 
Cvirt-sandbox-service-upgrade(1)
 
 =head1 FILES
 
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-perl][PATCH] Fix typo in domain help page

2013-05-20 Thread Zhe Peng
The help page of $dom-set_metadata have a typo,this patch fix it.
---
 lib/Sys/Virt/Domain.pm |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm
index a502029..053f127 100644
--- a/lib/Sys/Virt/Domain.pm
+++ b/lib/Sys/Virt/Domain.pm
@@ -112,7 +112,7 @@ C$flags parameter defaults to zero.
 Sets the metadata element of type C$type to hold the value
 C$val. If C$type is  CSys::Virt::Domain::METADATA_ELEMENT
 then the C$key and C$uri elements specify an XML namespace
-to use, otherwise they should both be Cnudef. The optional
+to use, otherwise they should both be Cundef. The optional
 C$flags parameter defaults to zero.
 
 =item $dom-is_active()
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [libvirt-tck PATCH v2 3/3] add new script for migration max speed

2013-05-14 Thread Zhe Peng
Get it, very thanks!

- Original Message -
 From: Eric Blake ebl...@redhat.com
 Cc: Daniel P. Berrange berra...@redhat.com, Zhe Peng 
 zp...@redhat.com, libvir-list@redhat.com
 Sent: Wednesday, May 15, 2013 1:01:24 AM
 Subject: Re: [libvirt] [libvirt-tck PATCH v2 3/3] add new script for 
 migration max speed
 
 On 05/14/2013 10:58 AM, Eric Blake wrote:
  On 05/14/2013 08:50 AM, Daniel P. Berrange wrote:
  On Fri, May 10, 2013 at 03:17:54PM +0800, Zhe Peng wrote:
  new script for migrate max speed APIs
  dom-migrate_get_max_speed
  dom-migrate_set_max_speed
  ---
   scripts/domain/301-migration-max-speed.t |   64
   
   1 files changed, 64 insertions(+), 0 deletions(-)
   create mode 100644 scripts/domain/301-migration-max-speed.t
 
  ACK
  
  All three patches pushed now.
 
 Minor correction - my attempt to push was rejected until I touched up
 your patch to fix these whitespace problems:
 
 Compressing objects: 100% (15/15), done.
 Writing objects: 100% (15/15), 4.29 KiB, done.
 Total 15 (delta 10), reused 0 (delta 0)
 remote: scripts/domain/121-block-info.t:19: trailing whitespace.
 remote: +domain/121-block-info.t
 remote: scripts/domain/121-block-info.t:128: trailing whitespace.
 remote: +#qcow2 file start with hexadecimal:0x51 0x46 0x49 (ASCII: QFI)
 remote: scripts/domain/121-block-info.t:1: new blank line at EOF.
 remote: scripts/domain/180-interface-parameters.t:19: trailing whitespace.
 remote: +domain/180-interface-parameters.t - test interface set/get
 remote: scripts/domain/180-interface-parameters.t:59: trailing whitespace.
 remote: +my %params = (Sys::Virt::Domain::BANDWIDTH_IN_AVERAGE=1000,
 Sys::Virt::Domain::BANDWIDTH_IN_PEAK=1001,
 remote: scripts/domain/180-interface-parameters.t:60: trailing whitespace.
 remote: +  Sys::Virt::Domain::BANDWIDTH_IN_BURST=1002,
 Sys::Virt::Domain::BANDWIDTH_OUT_AVERAGE=1003,
 remote: scripts/domain/301-migration-max-speed.t:19: trailing whitespace.
 remote: +domain/301-migrate-max-speed.t - test migrate max speed set/get
 remote: scripts/domain/301-migration-max-speed.t:1: new blank line at EOF.
 remote: error: hook declined to update refs/heads/master
 To ssh://libvirt.org/git//libvirt-tck.git
  ! [remote rejected] master - master (hook declined)
 
 You can set up git to refuse bad whitespace locally, to make it easier
 for others to not have to clean up your patches later.
 
 --
 Eric Blake   eblake redhat com+1-919-301-3266
 Libvirt virtualization library http://libvirt.org
 
 

-- 
Best Regards
Zhe Peng

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-tck PATCH v2 1/3] add three APIs testing for block

2013-05-10 Thread Zhe Peng
new script for block APIs
dom-block_resize
dom-get_block_info
dom-block_peek
---
 scripts/domain/121-block-info.t |  137 +++
 1 files changed, 137 insertions(+), 0 deletions(-)
 create mode 100644 scripts/domain/121-block-info.t

diff --git a/scripts/domain/121-block-info.t b/scripts/domain/121-block-info.t
new file mode 100644
index 000..17ebb2e
--- /dev/null
+++ b/scripts/domain/121-block-info.t
@@ -0,0 +1,137 @@
+# -*- perl -*-
+#
+# Copyright (C) 2013 Red Hat, Inc.
+# Copyright (C) 2013 Zhe Peng zp...@redhat.com
+#
+# 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/121-block-info.t 
+
+=head1 DESCRIPTION
+
+The test case validates that all following APIs work well include
+dom-block_resize
+dom-get_block_info
+dom-block_peek
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 29;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+use File::stat;
+
+my $tck = Sys::Virt::TCK-new();
+my $conn = eval { $tck-setup(); };
+BAIL_OUT failed to setup test harness: $@ if $@;
+END {
+$tck-cleanup if $tck;
+}
+
+# test is_alive
+my $live = $conn-is_alive();
+ok($live  0, Connection is alive);
+
+my $xml = $tck-generic_pool(dir)-as_xml;
+
+diag Defining transient storage pool;
+my $pool;
+ok_pool(sub { $pool = $conn-define_storage_pool($xml) }, define transient 
storage pool);
+lives_ok(sub { $pool-build(0) }, built storage pool);
+lives_ok(sub { $pool-create }, started storage pool);
+
+my $volallocxml = $tck-generic_volume(tck, raw, 
1024*1024*50)-allocation(1024*1024*50)-as_xml;
+my ($vol, $path, $st);
+ok_volume { $vol = $pool-create_volume($volallocxml) } create fully 
allocated raw volume;
+
+my $volallocxml2 = $tck-generic_volume(tck2, raw, 
1024*1024*50)-allocation(1024*1024)-as_xml;
+my ($vol2, $path2, $st2);
+ok_volume { $vol2 = $pool-create_volume($volallocxml2) } create not fully 
allocated raw volume;
+
+my $volallocxml3 = $tck-generic_volume(tck3, qcow2, 
1024*1024*50)-allocation(1024*1024)-as_xml;
+my ($vol3, $path3, $st3);
+ok_volume { $vol3 = $pool-create_volume($volallocxml3) } create qcow2 
volume;
+
+$path = xpath($vol, string(/volume/target/path));
+$st = stat($path);
+ok($st, path $path exists);
+is($st-size, 1024*1024*50, size is 50M);
+
+$path2 = xpath($vol2, string(/volume/target/path));
+$st2 = stat($path2);
+ok($st2, path $path2 exists);
+
+$path3 = xpath($vol3, string(/volume/target/path));
+$st3 = stat($path3);
+ok($st3, path $path3 exists);
+
+diag Generic guest with pervious created vol;
+my $disktype = raw;
+my $dst = vda;
+my $dst2 = vdb;
+my $dst3 = vdc;
+my $guest = $tck-generic_domain(tck);
+$guest-rmdisk();
+
+$guest-disk(format = { name = qemu, type = $disktype }, type = file, 
src = $path, dst = $dst);
+$guest-disk(format = { name = qemu, type = $disktype }, type = file, 
src= $path2, dst = $dst2);
+$guest-disk(format = { name = qemu, type = qcow2 }, type = file, 
src= $path3, dst = $dst3);
+$guest-interface(type = network, source = default, model = virtio, 
mac = 52:54:00:22:22:22);
+
+$xml = $guest-as_xml;
+my $dom;
+ok_domain(sub { $dom = $conn-create_domain($xml) }, Create domain);
+$xml = $dom-get_xml_description();
+
+is($dom-get_block_info($dst2,0)-{capacity}, 1024*1024*50, Get disk capacity 
info);
+is($dom-get_block_info($dst2,0)-{allocation}, 1024*1024, Get disk 
allocation info);
+is($dom-get_block_info($dst2,0)-{physical}, 1024*1024, Get disk physical 
info);
+
+
+is($dom-get_block_info($dst,0)-{capacity}, 1024*1024*50, Get disk capacity 
info);
+is($dom-get_block_info($dst,0)-{allocation}, 1024*1024*50, Get disk 
allocation info);
+is($dom-get_block_info($dst,0)-{physical}, 1024*1024*50, Get disk physical 
info);
+
+diag Test block_resize;
+lives_ok(sub {$dom-block_resize($dst, 512*50)}, resize to 512*50 KB);
+$st = stat($path);
+is($st-size, 512*1024*50, size is 25M);
+
+is($dom-get_block_info($dst,0)-{capacity}, 1024*512*50, Get disk capacity 
info);
+is($dom-get_block_info($dst,0)-{allocation}, 1024*512*50, Get disk 
allocation info);
+is($dom-get_block_info($dst,0)-{physical}, 1024*512*50, Get disk physical 
info);
+
+lives_ok(sub {$dom-block_resize($dst, 1024*50)}, resize to 1024*50 KB);
+$st = stat($path);
+is($st-size, 1024*1024*50, size is 50M);
+
+diag Test block_peek;
+my $date = test;
+system(echo $date  $path);
+is($dom-block_peek($path,0,4,0), $date, Get date from raw image);
+
+#qcow2 file start with hexadecimal:0x51 0x46 0x49 (ASCII: QFI) 
+is($dom-block_peek($path3,0,3,0), QFI, Get date from qcow2 image);
+
+lives_ok(sub { $vol-delete(0) }, deleted volume);
+
+diag Destroy domain;
+$dom-destroy;
+
+ok_error(sub { $conn-get_domain_by_name(tck) }, NO_DOMAIN error raised 
from missing

[libvirt] [libvirt-tck PATCH v2 3/3] add new script for migration max speed

2013-05-10 Thread Zhe Peng
new script for migrate max speed APIs
dom-migrate_get_max_speed
dom-migrate_set_max_speed
---
 scripts/domain/301-migration-max-speed.t |   64 
 1 files changed, 64 insertions(+), 0 deletions(-)
 create mode 100644 scripts/domain/301-migration-max-speed.t

diff --git a/scripts/domain/301-migration-max-speed.t 
b/scripts/domain/301-migration-max-speed.t
new file mode 100644
index 000..a07d244
--- /dev/null
+++ b/scripts/domain/301-migration-max-speed.t
@@ -0,0 +1,64 @@
+# -*- perl -*-
+#
+# Copyright (C) 2013 Red Hat, Inc.
+# Copyright (C) 2013 Zhe Peng zp...@redhat.com
+#
+# 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/301-migrate-max-speed.t - test migrate max speed set/get 
+
+=head1 DESCRIPTION
+
+The test case validates that all following APIs work well include
+dom-migrate_get_max_speed
+dom-migrate_set_max_speed
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 5;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+use File::stat;
+
+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 $xml = $tck-generic_domain(tck)-as_xml;
+
+my $dom;
+ok_domain(sub { $dom = $conn-create_domain($xml) }, Create domain);
+
+diag Get migrate max speed;
+my $speed = $dom-migrate_get_max_speed();
+ok($speed, Get migrate max speed $speed);
+
+diag Set migrate max speed;
+$speed = 1;
+lives_ok(sub {$dom-migrate_set_max_speed($speed)}, Set max speed to $speed);
+my $get_speed = $dom-migrate_get_max_speed();
+is ($speed, $get_speed, Get speed same as set);
+
+diag Destroy domain;
+$dom-destroy;
+
+ok_error(sub { $conn-get_domain_by_name(tck) }, NO_DOMAIN error raised 
from missing domain, 42);
+
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-tck PATCH v2 2/3] add script for interface parameters

2013-05-10 Thread Zhe Peng
new script for interface parameters APIs
dom-get_interface_parameters
dom-set_interface_parameters
con-is_alive
---
 scripts/domain/180-interface-parameters.t |   84 +
 1 files changed, 84 insertions(+), 0 deletions(-)
 create mode 100644 scripts/domain/180-interface-parameters.t

diff --git a/scripts/domain/180-interface-parameters.t 
b/scripts/domain/180-interface-parameters.t
new file mode 100644
index 000..8b4cb0d
--- /dev/null
+++ b/scripts/domain/180-interface-parameters.t
@@ -0,0 +1,84 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012 Red Hat, Inc.
+# Copyright (C) 2012 Kyla Zhang weiz...@redhat.com
+#
+# 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/180-interface-parameters.t - test interface set/get 
+
+=head1 DESCRIPTION
+
+The test case validates that all following APIs work well include
+dom-get_interface_parameters
+dom-set_interface_parameters
+con-is_alive
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 10;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+use File::stat;
+
+my $tck = Sys::Virt::TCK-new();
+my $conn = eval { $tck-setup(); };
+BAIL_OUT failed to setup test harness: $@ if $@;
+END {
+$tck-cleanup if $tck;
+}
+
+# test is_alive
+my $live = $conn-is_alive();
+ok($live  0, Connection is alive);
+
+my $xml = $tck-generic_domain(tck)
+  -interface(type = network, source = default, model = 
virtio, mac = 52:54:00:22:22:22)
+  -as_xml;
+
+my $dom;
+ok_domain(sub { $dom = $conn-create_domain($xml) }, Create domain);
+$xml = $dom-get_xml_description();
+
+diag Set/Get interface parameters;
+my %params = (Sys::Virt::Domain::BANDWIDTH_IN_AVERAGE=1000, 
Sys::Virt::Domain::BANDWIDTH_IN_PEAK=1001, 
+  Sys::Virt::Domain::BANDWIDTH_IN_BURST=1002, 
Sys::Virt::Domain::BANDWIDTH_OUT_AVERAGE=1003, 
+  Sys::Virt::Domain::BANDWIDTH_OUT_PEAK=1004, 
Sys::Virt::Domain::BANDWIDTH_OUT_BURST=1005);
+lives_ok(sub {$dom-set_interface_parameters(vnet0, \%params)}, Set vnet0 
parameters);
+for my $key (sort keys %params) {
+ diag Set $key = $params{$key} ;
+}
+
+my $param = $dom-get_interface_parameters(vnet0, 0);
+my $in_average = $param-{Sys::Virt::Domain::BANDWIDTH_IN_AVERAGE};
+my $in_burst = $param-{Sys::Virt::Domain::BANDWIDTH_IN_BURST};
+my $in_peak = $param-{Sys::Virt::Domain::BANDWIDTH_IN_PEAK};
+my $out_average = $param-{Sys::Virt::Domain::BANDWIDTH_OUT_AVERAGE};
+my $out_burst = $param-{Sys::Virt::Domain::BANDWIDTH_OUT_BURST};
+my $out_peak = $param-{Sys::Virt::Domain::BANDWIDTH_OUT_PEAK};
+is($in_average, 1000, Get inbound average 1000);
+is($in_burst, 1002, Get inbound burst 1002);
+is($in_peak, 1001, Get inbound peak 1001);
+is($out_average, 1003, Get outbound average 1003);
+is($out_burst, 1005, Get outbound burst 1005);
+is($out_peak, 1004, Get outbound peak 1004);
+
+diag Destroy domain;
+$dom-destroy;
+
+ok_error(sub { $conn-get_domain_by_name(tck) }, NO_DOMAIN error raised 
from missing domain, 42);
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-tck PATCH] Add new file for domain APIs

2013-05-08 Thread Zhe Peng
include APIs
dom-block_resize
dom-get_block_info
dom-block_peek
dom-get_interface_parameters
dom-migrate_get_max_speed
dom-set_interface_parameters
con-is_alive
---
 scripts/domain/180-interface-parameters.t |  173 +
 1 files changed, 173 insertions(+), 0 deletions(-)
 create mode 100644 scripts/domain/180-interface-parameters.t

diff --git a/scripts/domain/180-interface-parameters.t 
b/scripts/domain/180-interface-parameters.t
new file mode 100644
index 000..6b30a30
--- /dev/null
+++ b/scripts/domain/180-interface-parameters.t
@@ -0,0 +1,173 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012 Red Hat, Inc.
+# Copyright (C) 2012 Kyla Zhang weiz...@redhat.com
+#
+# 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/180-interface-parameters.t - test interface set/get 
+
+=head1 DESCRIPTION
+
+The test case validates that all following APIs work well include
+dom-block_resize
+dom-get_block_info
+dom-block_peek
+dom-get_interface_parameters
+dom-migrate_get_max_speed
+dom-set_interface_parameters
+con-is_alive
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 39;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+use File::stat;
+
+my $tck = Sys::Virt::TCK-new();
+my $conn = eval { $tck-setup(); };
+BAIL_OUT failed to setup test harness: $@ if $@;
+END {
+$tck-cleanup if $tck;
+}
+
+# test is_alive
+my $live = $conn-is_alive();
+ok($live  0, Connection is alive);
+
+my $xml = $tck-generic_pool(dir)-as_xml;
+
+diag Defining transient storage pool;
+my $pool;
+ok_pool(sub { $pool = $conn-define_storage_pool($xml) }, define transient 
storage pool);
+lives_ok(sub { $pool-build(0) }, built storage pool);
+lives_ok(sub { $pool-create }, started storage pool);
+
+my $volallocxml = $tck-generic_volume(tck, raw, 
1024*1024*50)-allocation(1024*1024*50)-as_xml;
+my ($vol, $path, $st);
+ok_volume { $vol = $pool-create_volume($volallocxml) } create fully 
allocated raw volume;
+
+my $volallocxml2 = $tck-generic_volume(tck2, raw, 
1024*1024*50)-allocation(1024*1024)-as_xml;
+my ($vol2, $path2, $st2);
+ok_volume { $vol2 = $pool-create_volume($volallocxml2) } create not fully 
allocated raw volume;
+
+my $volallocxml3 = $tck-generic_volume(tck3, qcow2, 
1024*1024*50)-allocation(1024*1024)-as_xml;
+my ($vol3, $path3, $st3);
+ok_volume { $vol3 = $pool-create_volume($volallocxml3) } create qcow2 
volume;
+
+$path = xpath($vol, string(/volume/target/path));
+$st = stat($path);
+ok($st, path $path exists);
+is($st-size, 1024*1024*50, size is 50M);
+
+$path2 = xpath($vol2, string(/volume/target/path));
+$st2 = stat($path2);
+ok($st2, path $path2 exists);
+
+$path3 = xpath($vol3, string(/volume/target/path));
+$st3 = stat($path3);
+ok($st3, path $path3 exists);
+
+diag Generic guest with pervious created vol;
+my $disktype = raw;
+my $dst = vda;
+my $dst2 = vdb;
+my $dst3 = vdc;
+my $guest = $tck-generic_domain(tck);
+$guest-rmdisk();
+$guest-disk(format = { name = qemu, type = $disktype }, type = file, 
src = $path, dst = $dst);
+$guest-disk(format = { name = qemu, type = $disktype }, type = file, 
src= $path2, dst = $dst2);
+$guest-disk(format = { name = qemu, type = qcow2 }, type = file, 
src= $path3, dst = $dst3);
+$guest-interface(type = network, source = default, model = virtio, 
mac = 52:54:00:22:22:22);
+
+$xml = $guest-as_xml;
+my $dom;
+ok_domain(sub { $dom = $conn-create_domain($xml) }, Create domain);
+$xml = $dom-get_xml_description();
+diag $xml;
+
+is($dom-get_block_info($dst2,0)-{capacity}, 1024*1024*50, Get disk capacity 
info);
+is($dom-get_block_info($dst2,0)-{allocation}, 1024*1024, Get disk 
allocation info);
+is($dom-get_block_info($dst2,0)-{physical}, 1024*1024, Get disk physical 
info);
+
+
+is($dom-get_block_info($dst,0)-{capacity}, 1024*1024*50, Get disk capacity 
info);
+is($dom-get_block_info($dst,0)-{allocation}, 1024*1024*50, Get disk 
allocation info);
+is($dom-get_block_info($dst,0)-{physical}, 1024*1024*50, Get disk physical 
info);
+
+diag Test block_resize;
+lives_ok(sub {$dom-block_resize($dst, 512*50)}, resize to 512*50 KB);
+$st = stat($path);
+is($st-size, 512*1024*50, size is 25M);
+
+is($dom-get_block_info($dst,0)-{capacity}, 1024*512*50, Get disk capacity 
info);
+is($dom-get_block_info($dst,0)-{allocation}, 1024*512*50, Get disk 
allocation info);
+is($dom-get_block_info($dst,0)-{physical}, 1024*512*50, Get disk physical 
info);
+
+lives_ok(sub {$dom-block_resize($dst, 1024*50)}, resize to 1024*50 KB);
+$st = stat($path);
+is($st-size, 1024*1024*50, size is 50M);
+
+my $date = test;
+system(echo $date  $path);
+is($dom-block_peek($path,0,4,0), $date, Get date from raw image);
+
+#qcow2 file start with hexadecimal:0x51 0x46 0x49 (ASCII: QFI) 

[libvirt] [libvirt-perl][PATCH] Fix typo in domain help page

2013-04-25 Thread Zhe Peng
The help page of $dom-set_metadata have a typo,this patch fix it.
---
 lib/Sys/Virt/Domain.pm |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/Sys/Virt/Domain.pm b/lib/Sys/Virt/Domain.pm
index a502029..053f127 100644
--- a/lib/Sys/Virt/Domain.pm
+++ b/lib/Sys/Virt/Domain.pm
@@ -112,7 +112,7 @@ C$flags parameter defaults to zero.
 Sets the metadata element of type C$type to hold the value
 C$val. If C$type is  CSys::Virt::Domain::METADATA_ELEMENT
 then the C$key and C$uri elements specify an XML namespace
-to use, otherwise they should both be Cnudef. The optional
+to use, otherwise they should both be Cundef. The optional
 C$flags parameter defaults to zero.
 
 =item $dom-is_active()
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-tck PATCH 1/2] New test for metadata

2013-04-24 Thread Zhe Peng
new script for testing get/set metadata
include API:
dom-get_metadata
dom-set_metadata
---
 scripts/domain/310-set-get-metadata.t |   68 +
 1 files changed, 68 insertions(+), 0 deletions(-)
 create mode 100644 scripts/domain/310-set-get-metadata.t

diff --git a/scripts/domain/310-set-get-metadata.t 
b/scripts/domain/310-set-get-metadata.t
new file mode 100644
index 000..d1e67a4
--- /dev/null
+++ b/scripts/domain/310-set-get-metadata.t
@@ -0,0 +1,68 @@
+# -*- perl -*-
+#
+# Copyright (C) 2009-2013 Red Hat, Inc.
+# Copyright (C) 2013 Zhe Peng
+#
+# 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/310-set-get-metadata.t - Domain set_metadata/set_metadata
+
+=head1 DESCRIPTION
+
+The test case validates that set_metadata and get_metadata all can worked.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 6;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+
+my $tck = Sys::Virt::TCK-new();
+my $conn = eval { $tck-setup(); };
+my $description = Test description;
+my $title = Test Title;
+BAIL_OUT failed to setup test harness: $@ if $@;
+END { $tck-cleanup if $tck; }
+
+
+my $xml = $tck-generic_domain(tck)-as_xml;
+
+diag Creating a new transient domain;
+my $dom;
+ok_domain(sub { $dom = $conn-create_domain($xml) }, created transient domain 
object);
+
+#set  get metadata for description
+lives_ok(sub 
{$dom-set_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,$description,undef,undef,0)},set
 metadata for Description);
+
+is($dom-get_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,undef,0), 
$description, get metadata for Description);
+
+#set  get metadata for title
+lives_ok(sub 
{$dom-set_metadata(Sys::Virt::Domain::METADATA_TITLE,$title,undef,undef,0)},set
 metadata for Title);
+
+is($dom-get_metadata(Sys::Virt::Domain::METADATA_TITLE,undef,0), $title, get 
metadata for Title);
+
+#clean
+diag Destroying the transient domain;
+$dom-destroy;
+
+diag Checking that transient domain has gone away;
+ok_error(sub { $conn-get_domain_by_name(tck) }, NO_DOMAIN error raised 
from missing domain,
+Sys::Virt::Error::ERR_NO_DOMAIN);
+
+# end
+
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-tck PATCH 2/2] Add script for managed save

2013-04-24 Thread Zhe Peng
new script for testing managed save
include API:
dom-has_managed_save_image
dom-managed_save_remove
---
 scripts/domain/320-managed_save_lifecycle.t |   74 +++
 1 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 scripts/domain/320-managed_save_lifecycle.t

diff --git a/scripts/domain/320-managed_save_lifecycle.t 
b/scripts/domain/320-managed_save_lifecycle.t
new file mode 100644
index 000..d0989f9
--- /dev/null
+++ b/scripts/domain/320-managed_save_lifecycle.t
@@ -0,0 +1,74 @@
+# -*- perl -*-
+#
+# Copyright (C) 2013 Red Hat, Inc.
+# Copyright (C) 2013 Zhe Peng zp...@redhat.com
+# 
+# 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/320-managed_save_lifecycle.t - Test API include
+dom-has_managed_save_image
+dom-managed_save_remove
+
+=head1 DESCRIPTION
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests = 9;
+
+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 $xml = $tck-generic_domain(tck)-as_xml;
+
+# Creating a new persistent domain
+my $dom;
+ok_domain(sub { $dom = $conn-define_domain($xml) }, Define persistent domain 
object, tck);
+
+diag Start domain;
+$dom-create;
+ok($dom-get_id()  0, running domain has an ID  0);
+
+#Check managed save before save
+is($dom-has_managed_save_image,0,No managed save for domain tck);
+
+#Managed save domain
+lives_ok(sub {$dom-managed_save;}, Managed save domain tck);
+
+ok_domain(sub {$conn-list_all_domains(Sys::Virt::Domain::LIST_MANAGEDSAVE);}, 
List all managed save domain, tck);
+
+#Check managed save after save
+is($dom-has_managed_save_image,1,Have managed save for domain tck);
+
+#Remove managed save for domain
+lives_ok(sub {$dom-managed_save_remove}, Remove managed save for domain 
tck);
+
+#Check managed save after remove
+is($dom-has_managed_save_image,0,No managed save for domain tck);
+
+diag Undefining the inactive domain config;
+$dom-undefine;
+
+diag Checking that persistent domain has gone away;
+ok_error(sub { $conn-get_domain_by_name(tck) }, NO_DOMAIN error raised 
from missing domain,
+Sys::Virt::Error::ERR_NO_DOMAIN);
+
+# end
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list