[libvirt] [PATCH 0/4] Alter domain_conf to make use of autofree
by John Ferlan
Adding to the recent hype for autofree... It's more than just saving
a few lines - in some cases the code is easier to read too. The last
patch is really long - I suppose it could be broken up as could perhaps
domain_conf into more easily process-able units.
John Ferlan (4):
conf: Use VIR_STEAL_PTR in domain_conf
conf: Use VIR_AUTOPTR(virBitmap) in domain_conf
conf: Fix XML ctxt swap in virDomainNetDefParseXML
conf: Use VIR_AUTOFREE in domain_conf
src/conf/domain_conf.c | 2108 ++++++++++++++--------------------------
1 file changed, 737 insertions(+), 1371 deletions(-)
--
2.20.1
5 years, 9 months
[libvirt] [PATCH] testutils: Explicitly name virTestCompare*() arguments
by Michal Privoznik
Currently, some arguments are called strcontent and strsrc, or
content and src or some other combination. This makes it
impossible to see at the first glance what argument is supposed
to represent 'expected' value and which one represents 'actual'
value. Rename the arguments to make it obvious.
At the same time, rework virTestCompareToULL a bit so that local
variables are named in the same fashion.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/testutils.c | 51 +++++++++++++++++------------------------------
tests/testutils.h | 10 +++++-----
2 files changed, 23 insertions(+), 38 deletions(-)
diff --git a/tests/testutils.c b/tests/testutils.c
index d2219ad21e..59c1d1fd6e 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -767,19 +767,19 @@ int virTestDifferenceBin(FILE *stream,
}
/*
- * @param strcontent: String input content
- * @param filename: File to compare strcontent against
+ * @param actual: String input content
+ * @param filename: File to compare @actual against
*
- * If @strcontent is NULL, it's treated as an empty string.
+ * If @actual is NULL, it's treated as an empty string.
*/
int
-virTestCompareToFile(const char *strcontent,
+virTestCompareToFile(const char *actual,
const char *filename)
{
int ret = -1;
char *filecontent = NULL;
char *fixedcontent = NULL;
- const char *cmpcontent = strcontent;
+ const char *cmpcontent = actual;
if (!cmpcontent)
cmpcontent = "";
@@ -814,43 +814,28 @@ virTestCompareToFile(const char *strcontent,
return ret;
}
-/*
- * @param content: Input content
- * @param src: Source to compare @content against
- */
int
-virTestCompareToULL(unsigned long long content,
- unsigned long long src)
+virTestCompareToULL(unsigned long long expected,
+ unsigned long long actual)
{
- char *strcontent = NULL;
- char *strsrc = NULL;
- int ret = -1;
+ VIR_AUTOFREE(char *) expectedStr = NULL;
+ VIR_AUTOFREE(char *) actualStr = NULL;
- if (virAsprintf(&strcontent, "%llu", content) < 0)
- goto cleanup;
+ if (virAsprintf(&expectedStr, "%llu", expected) < 0)
+ return -1;
- if (virAsprintf(&strsrc, "%llu", src) < 0)
- goto cleanup;
+ if (virAsprintf(&actualStr, "%llu", actual) < 0)
+ return -1;
- ret = virTestCompareToString(strcontent, strsrc);
-
- cleanup:
- VIR_FREE(strcontent);
- VIR_FREE(strsrc);
-
- return ret;
+ return virTestCompareToString(expectedStr, actualStr);
}
-/*
- * @param strcontent: String input content
- * @param strsrc: String source to compare strcontent against
- */
int
-virTestCompareToString(const char *strcontent,
- const char *strsrc)
+virTestCompareToString(const char *expected,
+ const char *actual)
{
- if (STRNEQ_NULLABLE(strcontent, strsrc)) {
- virTestDifference(stderr, strcontent, strsrc);
+ if (STRNEQ_NULLABLE(expected, actual)) {
+ virTestDifference(stderr, expected, actual);
return -1;
}
diff --git a/tests/testutils.h b/tests/testutils.h
index 658f9053ad..1ed9f0b6d3 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -76,12 +76,12 @@ int virTestDifferenceBin(FILE *stream,
const char *expect,
const char *actual,
size_t length);
-int virTestCompareToFile(const char *strcontent,
+int virTestCompareToFile(const char *actual,
const char *filename);
-int virTestCompareToString(const char *strcontent,
- const char *strsrc);
-int virTestCompareToULL(unsigned long long content,
- unsigned long long src);
+int virTestCompareToString(const char *expected,
+ const char *actual);
+int virTestCompareToULL(unsigned long long expected,
+ unsigned long long actual);
unsigned int virTestGetDebug(void);
unsigned int virTestGetVerbose(void);
--
2.19.2
5 years, 9 months
[libvirt] [glib PATCH 00/15] po: improve translation handling
by Daniel P. Berrangé
This applies the same improvements previously done in libvirt:
https://www.redhat.com/archives/libvir-list/2018-April/msg01004.html
https://www.berrange.com/posts/2018/11/29/improved-translation-po-file-ha...
The key problems with our current approach are:
- The pot & po files stored in GIT contain huge set of
annotations about source file names & line numbers.
These are out of date as soon as a change is commited
to git following a translation refresh. This makes
diffs impossible to meaningfully review, as they are
98% noise, 2% signal.
- The po file messages are sorted by source location,
so when we move code between files, or rename files,
the po file message order changes for no good reason.
This makes diffs even more impossible to review.
- The po files contain entries for all messages even
if most have no translation, bloating size of po/
data stored in git
- Whenever 'make dist' is run, it alters all the pot
and po files, so developers need to then reset their
content to match git HEAD manually. This is caused
by having auto-generated content (source file locations)
mixed in with the static content (the actual translated
strings)
After this series, we only minimized po files in git, with
the redundated & outdated source locations info stripped.
This stripped info is re-added automatically during build
to create the real .po files, that we distribute, and/or
upload to translators in Zanata.
As a result the po directory is smaller in size, and
when refreshing from Zanata, we have git commits that
clearly show *only* the altered translations, nothing
else. The importance of this cannot be overstated - by
having these clear diffs when doing this change in libvirt,
I discovered a serious bug in the Zanata client that has
been screwing up translations in every project that uses
Zanata by adding bogus "fuzzy" annotations.
The particularly attractive statistic:
194 files changed, 2607 insertions(+), 14146 deletions(-)
Daniel P. Berrangé (15):
po: provide custom make rules for po file management
po: remove language list from zanata configuration
po: add rules for integration with zanata
po: minimize & canonicalize translations stored in git
po: minimize af am anp ar as ast bal be bg bn_IN
po: minimize bn bo br brx bs ca cs cy da de_CH
po: minimize de el en_GB eo es et eu fa fi
po: minimize fr gl gu he hi hr hu ia
po: minimize id ilo is it ja ka kk km kn ko
po: minimize kw_GB kw@kkcor kw kw@uccor ky lt lv mai mk ml
po: minimize mn mr ms nb nds ne nl nn nso
po: minimize or pa pl pt_BR pt ro ru si sk sl
po: minimize sq sr@latin sr sv ta te tg th tr tw
po: minimize uk ur vi wba yo zh_CN zh_HK zh_TW zu
po: refresh translations from zanata
.gitignore | 10 +--
autogen.sh | 3 +-
build-aux/minimize-po.pl | 37 ++++++++
configure.ac | 8 +-
libvirt-gconfig/Makefile.am | 1 +
libvirt-glib/Makefile.am | 1 +
libvirt-gobject/Makefile.am | 1 +
m4/virt-gettext.m4 | 5 --
m4/virt-nls.m4 | 45 ++++++++++
po/Makefile.am | 111 +++++++++++++++++++++++
po/{POTFILES.in => POTFILES} | 0
po/README.md | 76 ++++++++++++++++
po/af.mini.po | 20 +++++
po/af.po | 153 --------------------------------
po/am.mini.po | 20 +++++
po/am.po | 153 --------------------------------
po/anp.mini.po | 19 ++++
po/anp.po | 152 -------------------------------
po/ar.mini.po | 21 +++++
po/ar.po | 154 --------------------------------
po/as.mini.po | 20 +++++
po/as.po | 153 --------------------------------
po/ast.mini.po | 20 +++++
po/ast.po | 153 --------------------------------
po/bal.mini.po | 20 +++++
po/bal.po | 153 --------------------------------
po/be.mini.po | 21 +++++
po/be.po | 154 --------------------------------
po/bg.mini.po | 20 +++++
po/bg.po | 153 --------------------------------
po/bn.mini.po | 20 +++++
po/bn.po | 153 --------------------------------
po/bn_IN.mini.po | 20 +++++
po/bn_IN.po | 153 --------------------------------
po/bo.mini.po | 20 +++++
po/bo.po | 153 --------------------------------
po/br.mini.po | 20 +++++
po/br.po | 153 --------------------------------
po/brx.mini.po | 20 +++++
po/brx.po | 153 --------------------------------
po/bs.mini.po | 21 +++++
po/bs.po | 154 --------------------------------
po/{ca.po => ca.mini.po} | 152 ++++++++++++-------------------
po/cs.mini.po | 119 +++++++++++++++++++++++++
po/cs.po | 155 --------------------------------
po/cy.mini.po | 21 +++++
po/cy.po | 154 --------------------------------
po/da.mini.po | 20 +++++
po/da.po | 153 --------------------------------
po/de.mini.po | 20 +++++
po/de.po | 153 --------------------------------
po/de_CH.mini.po | 20 +++++
po/de_CH.po | 153 --------------------------------
po/el.mini.po | 20 +++++
po/el.po | 153 --------------------------------
po/{en_GB.po => en_GB.mini.po} | 141 ++++++++++-------------------
po/eo.mini.po | 20 +++++
po/eo.po | 153 --------------------------------
po/{es.po => es.mini.po} | 153 ++++++++++++--------------------
po/et.mini.po | 20 +++++
po/et.po | 153 --------------------------------
po/eu.mini.po | 20 +++++
po/eu.po | 153 --------------------------------
po/fa.mini.po | 20 +++++
po/fa.po | 153 --------------------------------
po/fi.mini.po | 44 +++++++++
po/fi.po | 154 --------------------------------
po/{fr.po => fr.mini.po} | 157 +++++++++++++--------------------
po/gl.mini.po | 20 +++++
po/gl.po | 153 --------------------------------
po/gu.mini.po | 20 +++++
po/gu.po | 153 --------------------------------
po/he.mini.po | 20 +++++
po/he.po | 153 --------------------------------
po/{hi.po => hi.mini.po} | 141 ++++++++++-------------------
po/hr.mini.po | 21 +++++
po/hr.po | 154 --------------------------------
po/hu.mini.po | 20 +++++
po/hu.po | 153 --------------------------------
po/ia.mini.po | 20 +++++
po/ia.po | 153 --------------------------------
po/id.mini.po | 20 +++++
po/id.po | 153 --------------------------------
po/ilo.mini.po | 20 +++++
po/ilo.po | 153 --------------------------------
po/is.mini.po | 20 +++++
po/is.po | 153 --------------------------------
po/it.mini.po | 20 +++++
po/it.po | 153 --------------------------------
po/{ja.po => ja.mini.po} | 141 ++++++++++-------------------
po/ka.mini.po | 20 +++++
po/ka.po | 153 --------------------------------
po/kk.mini.po | 20 +++++
po/kk.po | 153 --------------------------------
po/km.mini.po | 20 +++++
po/km.po | 153 --------------------------------
po/kn.mini.po | 20 +++++
po/kn.po | 153 --------------------------------
po/ko.mini.po | 20 +++++
po/ko.po | 153 --------------------------------
po/kw.mini.po | 20 +++++
po/kw.po | 153 --------------------------------
po/kw(a)kkcor.mini.po | 20 +++++
po/kw(a)kkcor.po | 153 --------------------------------
po/kw(a)uccor.mini.po | 20 +++++
po/kw(a)uccor.po | 153 --------------------------------
po/kw_GB.mini.po | 20 +++++
po/kw_GB.po | 153 --------------------------------
po/ky.mini.po | 20 +++++
po/ky.po | 153 --------------------------------
po/lt.mini.po | 21 +++++
po/lt.po | 154 --------------------------------
po/lv.mini.po | 21 +++++
po/lv.po | 154 --------------------------------
po/mai.mini.po | 20 +++++
po/mai.po | 153 --------------------------------
po/mk.mini.po | 20 +++++
po/mk.po | 153 --------------------------------
po/ml.mini.po | 20 +++++
po/ml.po | 153 --------------------------------
po/mn.mini.po | 20 +++++
po/mn.po | 153 --------------------------------
po/mr.mini.po | 20 +++++
po/mr.po | 153 --------------------------------
po/ms.mini.po | 20 +++++
po/ms.po | 153 --------------------------------
po/nb.mini.po | 20 +++++
po/nb.po | 153 --------------------------------
po/nds.mini.po | 20 +++++
po/nds.po | 153 --------------------------------
po/ne.mini.po | 20 +++++
po/ne.po | 153 --------------------------------
po/nl.mini.po | 20 +++++
po/nl.po | 153 --------------------------------
po/nn.mini.po | 20 +++++
po/nn.po | 153 --------------------------------
po/nso.mini.po | 20 +++++
po/nso.po | 153 --------------------------------
po/or.mini.po | 20 +++++
po/or.po | 153 --------------------------------
po/pa.mini.po | 20 +++++
po/pa.po | 153 --------------------------------
po/{pl.po => pl.mini.po} | 152 ++++++++++++-------------------
po/pt.mini.po | 20 +++++
po/pt.po | 153 --------------------------------
po/{pt_BR.po => pt_BR.mini.po} | 141 ++++++++++-------------------
po/ro.mini.po | 21 +++++
po/ro.po | 154 --------------------------------
po/ru.mini.po | 26 ++++++
po/ru.po | 155 --------------------------------
po/si.mini.po | 20 +++++
po/si.po | 153 --------------------------------
po/sk.mini.po | 20 +++++
po/sk.po | 153 --------------------------------
po/sl.mini.po | 21 +++++
po/sl.po | 154 --------------------------------
po/sq.mini.po | 20 +++++
po/sq.po | 153 --------------------------------
po/sr.mini.po | 21 +++++
po/sr.po | 154 --------------------------------
po/sr(a)latin.mini.po | 21 +++++
po/sr(a)latin.po | 154 --------------------------------
po/sv.mini.po | 20 +++++
po/sv.po | 153 --------------------------------
po/ta.mini.po | 20 +++++
po/ta.po | 153 --------------------------------
po/te.mini.po | 20 +++++
po/te.po | 153 --------------------------------
po/tg.mini.po | 20 +++++
po/tg.po | 153 --------------------------------
po/th.mini.po | 20 +++++
po/th.po | 153 --------------------------------
po/tr.mini.po | 20 +++++
po/tr.po | 153 --------------------------------
po/tw.mini.po | 19 ++++
po/tw.po | 152 -------------------------------
po/{uk.po => uk.mini.po} | 152 ++++++++++++-------------------
po/ur.mini.po | 20 +++++
po/ur.po | 153 --------------------------------
po/vi.mini.po | 20 +++++
po/vi.po | 153 --------------------------------
po/wba.mini.po | 19 ++++
po/wba.po | 152 -------------------------------
po/yo.mini.po | 19 ++++
po/yo.po | 152 -------------------------------
po/zanata.xml | 99 ---------------------
po/zh_CN.mini.po | 20 +++++
po/zh_CN.po | 153 --------------------------------
po/zh_HK.mini.po | 20 +++++
po/zh_HK.po | 153 --------------------------------
po/zh_TW.mini.po | 20 +++++
po/zh_TW.po | 153 --------------------------------
po/zu.mini.po | 20 +++++
po/zu.po | 153 --------------------------------
194 files changed, 2607 insertions(+), 14146 deletions(-)
create mode 100755 build-aux/minimize-po.pl
delete mode 100644 m4/virt-gettext.m4
create mode 100644 m4/virt-nls.m4
create mode 100644 po/Makefile.am
rename po/{POTFILES.in => POTFILES} (100%)
create mode 100644 po/README.md
create mode 100644 po/af.mini.po
delete mode 100644 po/af.po
create mode 100644 po/am.mini.po
delete mode 100644 po/am.po
create mode 100644 po/anp.mini.po
delete mode 100644 po/anp.po
create mode 100644 po/ar.mini.po
delete mode 100644 po/ar.po
create mode 100644 po/as.mini.po
delete mode 100644 po/as.po
create mode 100644 po/ast.mini.po
delete mode 100644 po/ast.po
create mode 100644 po/bal.mini.po
delete mode 100644 po/bal.po
create mode 100644 po/be.mini.po
delete mode 100644 po/be.po
create mode 100644 po/bg.mini.po
delete mode 100644 po/bg.po
create mode 100644 po/bn.mini.po
delete mode 100644 po/bn.po
create mode 100644 po/bn_IN.mini.po
delete mode 100644 po/bn_IN.po
create mode 100644 po/bo.mini.po
delete mode 100644 po/bo.po
create mode 100644 po/br.mini.po
delete mode 100644 po/br.po
create mode 100644 po/brx.mini.po
delete mode 100644 po/brx.po
create mode 100644 po/bs.mini.po
delete mode 100644 po/bs.po
rename po/{ca.po => ca.mini.po} (62%)
create mode 100644 po/cs.mini.po
delete mode 100644 po/cs.po
create mode 100644 po/cy.mini.po
delete mode 100644 po/cy.po
create mode 100644 po/da.mini.po
delete mode 100644 po/da.po
create mode 100644 po/de.mini.po
delete mode 100644 po/de.po
create mode 100644 po/de_CH.mini.po
delete mode 100644 po/de_CH.po
create mode 100644 po/el.mini.po
delete mode 100644 po/el.po
rename po/{en_GB.po => en_GB.mini.po} (51%)
create mode 100644 po/eo.mini.po
delete mode 100644 po/eo.po
rename po/{es.po => es.mini.po} (59%)
create mode 100644 po/et.mini.po
delete mode 100644 po/et.po
create mode 100644 po/eu.mini.po
delete mode 100644 po/eu.po
create mode 100644 po/fa.mini.po
delete mode 100644 po/fa.po
create mode 100644 po/fi.mini.po
delete mode 100644 po/fi.po
rename po/{fr.po => fr.mini.po} (59%)
create mode 100644 po/gl.mini.po
delete mode 100644 po/gl.po
create mode 100644 po/gu.mini.po
delete mode 100644 po/gu.po
create mode 100644 po/he.mini.po
delete mode 100644 po/he.po
rename po/{hi.po => hi.mini.po} (62%)
create mode 100644 po/hr.mini.po
delete mode 100644 po/hr.po
create mode 100644 po/hu.mini.po
delete mode 100644 po/hu.po
create mode 100644 po/ia.mini.po
delete mode 100644 po/ia.po
create mode 100644 po/id.mini.po
delete mode 100644 po/id.po
create mode 100644 po/ilo.mini.po
delete mode 100644 po/ilo.po
create mode 100644 po/is.mini.po
delete mode 100644 po/is.po
create mode 100644 po/it.mini.po
delete mode 100644 po/it.po
rename po/{ja.po => ja.mini.po} (55%)
create mode 100644 po/ka.mini.po
delete mode 100644 po/ka.po
create mode 100644 po/kk.mini.po
delete mode 100644 po/kk.po
create mode 100644 po/km.mini.po
delete mode 100644 po/km.po
create mode 100644 po/kn.mini.po
delete mode 100644 po/kn.po
create mode 100644 po/ko.mini.po
delete mode 100644 po/ko.po
create mode 100644 po/kw.mini.po
delete mode 100644 po/kw.po
create mode 100644 po/kw(a)kkcor.mini.po
delete mode 100644 po/kw(a)kkcor.po
create mode 100644 po/kw(a)uccor.mini.po
delete mode 100644 po/kw(a)uccor.po
create mode 100644 po/kw_GB.mini.po
delete mode 100644 po/kw_GB.po
create mode 100644 po/ky.mini.po
delete mode 100644 po/ky.po
create mode 100644 po/lt.mini.po
delete mode 100644 po/lt.po
create mode 100644 po/lv.mini.po
delete mode 100644 po/lv.po
create mode 100644 po/mai.mini.po
delete mode 100644 po/mai.po
create mode 100644 po/mk.mini.po
delete mode 100644 po/mk.po
create mode 100644 po/ml.mini.po
delete mode 100644 po/ml.po
create mode 100644 po/mn.mini.po
delete mode 100644 po/mn.po
create mode 100644 po/mr.mini.po
delete mode 100644 po/mr.po
create mode 100644 po/ms.mini.po
delete mode 100644 po/ms.po
create mode 100644 po/nb.mini.po
delete mode 100644 po/nb.po
create mode 100644 po/nds.mini.po
delete mode 100644 po/nds.po
create mode 100644 po/ne.mini.po
delete mode 100644 po/ne.po
create mode 100644 po/nl.mini.po
delete mode 100644 po/nl.po
create mode 100644 po/nn.mini.po
delete mode 100644 po/nn.po
create mode 100644 po/nso.mini.po
delete mode 100644 po/nso.po
create mode 100644 po/or.mini.po
delete mode 100644 po/or.po
create mode 100644 po/pa.mini.po
delete mode 100644 po/pa.po
rename po/{pl.po => pl.mini.po} (62%)
create mode 100644 po/pt.mini.po
delete mode 100644 po/pt.po
rename po/{pt_BR.po => pt_BR.mini.po} (54%)
create mode 100644 po/ro.mini.po
delete mode 100644 po/ro.po
create mode 100644 po/ru.mini.po
delete mode 100644 po/ru.po
create mode 100644 po/si.mini.po
delete mode 100644 po/si.po
create mode 100644 po/sk.mini.po
delete mode 100644 po/sk.po
create mode 100644 po/sl.mini.po
delete mode 100644 po/sl.po
create mode 100644 po/sq.mini.po
delete mode 100644 po/sq.po
create mode 100644 po/sr.mini.po
delete mode 100644 po/sr.po
create mode 100644 po/sr(a)latin.mini.po
delete mode 100644 po/sr(a)latin.po
create mode 100644 po/sv.mini.po
delete mode 100644 po/sv.po
create mode 100644 po/ta.mini.po
delete mode 100644 po/ta.po
create mode 100644 po/te.mini.po
delete mode 100644 po/te.po
create mode 100644 po/tg.mini.po
delete mode 100644 po/tg.po
create mode 100644 po/th.mini.po
delete mode 100644 po/th.po
create mode 100644 po/tr.mini.po
delete mode 100644 po/tr.po
create mode 100644 po/tw.mini.po
delete mode 100644 po/tw.po
rename po/{uk.po => uk.mini.po} (65%)
create mode 100644 po/ur.mini.po
delete mode 100644 po/ur.po
create mode 100644 po/vi.mini.po
delete mode 100644 po/vi.po
create mode 100644 po/wba.mini.po
delete mode 100644 po/wba.po
create mode 100644 po/yo.mini.po
delete mode 100644 po/yo.po
create mode 100644 po/zh_CN.mini.po
delete mode 100644 po/zh_CN.po
create mode 100644 po/zh_HK.mini.po
delete mode 100644 po/zh_HK.po
create mode 100644 po/zh_TW.mini.po
delete mode 100644 po/zh_TW.po
create mode 100644 po/zu.mini.po
delete mode 100644 po/zu.po
--
2.20.1
5 years, 9 months
[libvirt] [libvirt-php] [PATCH 1/1] Add function libvirt_domain_undefine_flags and libvirt_domain_snapshot_create_xml
by Zhensheng Yuan
Hi,
I created a patch for libvirt-php to support virDomainUndefineFlags and
create snapshot from XML string.
The test case file is
"examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php".
Hoping this is useful for libvirt-php.
>From e753d0014e8ce8cbcafb0fbd92159a6cc9f32168 Mon Sep 17 00:00:00 2001
From: Zhensheng Yuan <yuan(a)zhensheng.im>
Date: Wed, 20 Feb 2019 18:25:05 +0800
Subject: [libvirt-php PATCH] Add function libvirt_domain_undefine_flags and
libvirt_domain_snapshot_create_xml
---
...lags_and_snapshot_create_xml_test_case.php | 136 ++++++++++++++++++
src/libvirt-domain.c | 23 +++
src/libvirt-domain.h | 2 +
src/libvirt-php.c | 12 ++
src/libvirt-snapshot.c | 35 +++++
src/libvirt-snapshot.h | 2 +
6 files changed, 210 insertions(+)
create mode 100644
examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php
diff --git
a/examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php
b/examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php
new file mode 100644
index 0000000..e6590ae
--- /dev/null
+++ b/examples/domain_undefine_flags_and_snapshot_create_xml_test_case.php
@@ -0,0 +1,136 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * Date: 19-2-20
+ * Time: 下午4:57
+ */
+
+namespace YunInternet\Libvirt\Test\Unit;
+
+
+use PHPUnit\Framework\TestCase;
+
+class Test_libvirt_domain_undefine_flags extends TestCase
+{
+ public function testConstants()
+ {
+ $this->assertEquals(VIR_DOMAIN_UNDEFINE_MANAGED_SAVE, 1);
+ $this->assertEquals(VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, 2);
+ $this->assertEquals(VIR_DOMAIN_UNDEFINE_NVRAM, 4);
+ $this->assertEquals(VIR_DOMAIN_UNDEFINE_KEEP_NVRAM, 8);
+ }
+
+ public function testSnapshotAndUndefineFlags()
+ {
+ $libvirtResource = libvirt_connect("test:///default", false);
+ $this->assertTrue(is_resource($libvirtResource));
+
+ $domainResource = libvirt_domain_define_xml($libvirtResource,
$this->getDomainXML());
+ $this->assertTrue(is_resource($domainResource));
+
+ // Create a snapshot named snapshot1
+ $snapshotResource =
libvirt_domain_snapshot_create_xml($domainResource, <<<EOF
+<domainsnapshot>
+ <name>snapshot1</name>
+</domainsnapshot>
+EOF
+, VIR_SNAPSHOT_CREATE_LIVE | VIR_SNAPSHOT_CREATE_ATOMIC);
+ $this->assertTrue(is_resource($snapshotResource));
+
+ // Domain with snapshot can not be undefined directly
+ $this->assertFalse(@libvirt_domain_undefine($domainResource));
+
+ // Use VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA flag to undefine the
domain
+ $this->assertTrue(libvirt_domain_undefine_flags($domainResource,
VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA));
+ }
+
+ private function getDomainXML()
+ {
+ return <<<EOF
+<domain type="test">
+ <name>Test</name>
+ <memory unit="MiB">1024</memory>
+ <vcpu placement="static">8</vcpu>
+ <cpu mode="host-passthrough">
+ <topology sockets="4" cores="1" threads="2"/>
+ </cpu>
+ <os>
+ <type arch="i686">hvm</type>
+ <loader readonly='yes' type='pflash'>/usr/share/ovmf/OVMF.fd</loader>
+ <nvram
template='/usr/share/OVMF/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/guest_VARS.fd</nvram>
+ <bootmenu enable="yes" timeout="1000"/>
+ <boot dev="hd"/>
+ <boot dev="cdrom"/>
+ </os>
+ <pm>
+ <suspend-to-mem enable="yes"/>
+ </pm>
+ <devices>
+ <memballoon model="none"/>
+ <disk type="volume" device="disk">
+ <driver name="qemu" type="qcow2"/>
+ <source pool="testPool1" volume="testVolume1"/>
+ <target bus="virtio" dev="vda"/>
+ </disk>
+ <disk type="volume" device="disk">
+ <driver name="qemu" type="qcow2"/>
+ <source pool="testPool2" volume="testVolume2"/>
+ <target bus="virtio" dev="vdb"/>
+ <iotune>
+ <total_bytes_sec>102400</total_bytes_sec>
+ </iotune>
+ </disk>
+ <disk type="file" device="cdrom">
+ <driver name="qemu" type="raw"/>
+ <source file="/iso/iso.iso"/>
+ <target bus="ide" dev="hda"/>
+ </disk>
+ <interface type="network">
+ <source network="default"/>
+ <mac address="52:54:00:00:00:01"/>
+ <model type="virtio"/>
+ <filterref filter="clean-traffic">
+ <parameter name="IP" value="192.168.122.2"/>
+ </filterref>
+ <bandwidth>
+ <inbound average="10240" burst="20480" peak="20480"/>
+ <outbound average="10240" burst="20480" peak="20480"/>
+ </bandwidth>
+ </interface>
+ <input type="tablet" bus="usb"/>
+ <graphics type="vnc" passwd="12345678" port="-1" autoport="yes">
+ <listen type="address" address="0.0.0.0"/>
+ </graphics>
+ <channel>
+ <source mode="bind"/>
+ <target type="virtio" name="org.qemu.guest_agent.0"/>
+ </channel>
+ </devices>
+ <clock offset="utc"/>
+ <features>
+ <pae/>
+ <acpi/>
+ <apic/>
+ <hyperv>
+ <relaxed state="on"/>
+ <vapic state="on"/>
+ <spinlocks state="on" retries="8191"/>
+ </hyperv>
+ </features>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <blkiotune>
+ <weight>1000</weight>
+ <device>
+ <path>/dev/sda</path>
+ <weight>1000</weight>
+ <read_bytes_sec>10240</read_bytes_sec>
+ <write_bytes_sec>10240</write_bytes_sec>
+ </device>
+ </blkiotune>
+</domain>
+EOF
+ ;
+ }
+}
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 8b8bb45..e2dc33e 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -1467,6 +1467,29 @@ PHP_FUNCTION(libvirt_domain_undefine)
RETURN_TRUE;
}
+/*
+ * Function name: libvirt_domain_undefine_flags
+ * Description: Function is used to undefine(with flags) the domain
identified by it's resource
+ * Arguments: @res [resource]: libvirt domain resource, e.g. from
libvirt_domain_lookup_by_*()
+ * @flags [int]: optional flags
+ * Returns: TRUE for success, FALSE on error
+ */
+PHP_FUNCTION(libvirt_domain_undefine_flags)
+{
+ php_libvirt_domain *domain = NULL;
+ zval *zdomain;
+ int retval;
+ zend_long flags = 0;
+
+ GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags);
+
+ retval = virDomainUndefineFlags(domain->domain, flags);
+ DPRINTF("%s: virDomainUndefineFlags(%p) returned %d\n", PHPFUNC,
domain->domain, retval);
+ if (retval != 0)
+ RETURN_FALSE;
+ RETURN_TRUE;
+}
+
/*
* Function name: libvirt_domain_reboot
* Since version: 0.4.1(-1)
diff --git a/src/libvirt-domain.h b/src/libvirt-domain.h
index dc0ab46..6d98544 100644
--- a/src/libvirt-domain.h
+++ b/src/libvirt-domain.h
@@ -73,6 +73,7 @@
PHP_FE(libvirt_domain_suspend, arginfo_libvirt_conn)
\
PHP_FE(libvirt_domain_managedsave, arginfo_libvirt_conn)
\
PHP_FE(libvirt_domain_undefine, arginfo_libvirt_conn)
\
+ PHP_FE(libvirt_domain_undefine_flags,
arginfo_libvirt_conn_flags) \
PHP_FE(libvirt_domain_reboot,
arginfo_libvirt_conn_flags) \
PHP_FE(libvirt_domain_define_xml,
arginfo_libvirt_conn_xml) \
PHP_FE(libvirt_domain_create_xml,
arginfo_libvirt_conn_xml) \
@@ -163,6 +164,7 @@ PHP_FUNCTION(libvirt_domain_shutdown);
PHP_FUNCTION(libvirt_domain_suspend);
PHP_FUNCTION(libvirt_domain_managedsave);
PHP_FUNCTION(libvirt_domain_undefine);
+PHP_FUNCTION(libvirt_domain_undefine_flags);
PHP_FUNCTION(libvirt_domain_reboot);
PHP_FUNCTION(libvirt_domain_define_xml);
PHP_FUNCTION(libvirt_domain_create_xml);
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index cf8fd7f..7e10b3d 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -468,6 +468,12 @@ ZEND_ARG_INFO(0, timeout)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_domain_snapshot_create_xml, 0, 0, 2)
+ZEND_ARG_INFO(0, conn)
+ZEND_ARG_INFO(0, xml)
+ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
static zend_function_entry libvirt_functions[] = {
PHP_FE_LIBVIRT_CONNECTION
PHP_FE_LIBVIRT_STREAM
@@ -1491,6 +1497,12 @@ PHP_MINIT_FUNCTION(libvirt)
REGISTER_LONG_CONSTANT("VIR_KEYCODE_SET_WIN32", VIR_KEYCODE_SET_WIN32,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_KEYCODE_SET_RFB", VIR_KEYCODE_SET_RFB,
CONST_CS | CONST_PERSISTENT);
+ /* virDomainUndefineFlagsValues */
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_UNDEFINE_MANAGED_SAVE",
VIR_DOMAIN_UNDEFINE_MANAGED_SAVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA",
VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_UNDEFINE_NVRAM",
VIR_DOMAIN_UNDEFINE_NVRAM, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_DOMAIN_UNDEFINE_KEEP_NVRAM",
VIR_DOMAIN_UNDEFINE_KEEP_NVRAM, CONST_CS | CONST_PERSISTENT);
+
REGISTER_INI_ENTRIES();
/* Initialize libvirt and set up error callback */
diff --git a/src/libvirt-snapshot.c b/src/libvirt-snapshot.c
index 1388d88..f7e3e2b 100644
--- a/src/libvirt-snapshot.c
+++ b/src/libvirt-snapshot.c
@@ -130,6 +130,41 @@ PHP_FUNCTION(libvirt_domain_snapshot_create)
VIRT_REGISTER_RESOURCE(res_snapshot, le_libvirt_snapshot);
}
+/*
+ * Function name: libvirt_domain_snapshot_create_xml
+ * Description: This function creates the domain snapshot from XML
string for the domain identified by it's resource
+ * Arguments: @res [resource]: libvirt domain resource
+ * @xml [string]: xml
+ * @flags [int]: libvirt snapshot flags
+ * Returns: domain snapshot resource
+ */
+PHP_FUNCTION(libvirt_domain_snapshot_create_xml)
+{
+ php_libvirt_domain *domain = NULL;
+ php_libvirt_snapshot *res_snapshot;
+ zval *zdomain;
+ char *xml;
+ strsize_t xml_len;
+ virDomainSnapshotPtr snapshot = NULL;
+ zend_long flags = 0;
+
+ GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &xml, &xml_len, &flags);
+
+ snapshot = virDomainSnapshotCreateXML(domain->domain, xml, flags);
+ DPRINTF("%s: virDomainSnapshotCreateXML(%p, <xml>) returned %p\n",
PHPFUNC, domain->domain, snapshot);
+ if (snapshot == NULL)
+ RETURN_FALSE;
+
+ res_snapshot = (php_libvirt_snapshot
*)emalloc(sizeof(php_libvirt_snapshot));
+ res_snapshot->domain = domain;
+ res_snapshot->snapshot = snapshot;
+
+ DPRINTF("%s: returning %p\n", PHPFUNC, res_snapshot->snapshot);
+ resource_change_counter(INT_RESOURCE_SNAPSHOT, domain->conn->conn,
res_snapshot->snapshot, 1 TSRMLS_CC);
+
+ VIRT_REGISTER_RESOURCE(res_snapshot, le_libvirt_snapshot);
+}
+
/*
* Function name: libvirt_domain_snapshot_get_xml
* Since version: 0.4.1(-2)
diff --git a/src/libvirt-snapshot.h b/src/libvirt-snapshot.h
index e6092aa..970662c 100644
--- a/src/libvirt-snapshot.h
+++ b/src/libvirt-snapshot.h
@@ -16,6 +16,7 @@
PHP_FE(libvirt_domain_has_current_snapshot,
arginfo_libvirt_conn_optflags) \
PHP_FE(libvirt_domain_snapshot_lookup_by_name,
arginfo_libvirt_domain_snapshot_lookup_by_name) \
PHP_FE(libvirt_domain_snapshot_create,
arginfo_libvirt_conn_optflags) \
+ PHP_FE(libvirt_domain_snapshot_create_xml,
arginfo_libvirt_domain_snapshot_create_xml) \
PHP_FE(libvirt_domain_snapshot_get_xml,
arginfo_libvirt_conn_optflags) \
PHP_FE(libvirt_domain_snapshot_revert,
arginfo_libvirt_conn_optflags) \
PHP_FE(libvirt_domain_snapshot_delete,
arginfo_libvirt_conn_optflags) \
@@ -50,6 +51,7 @@ void php_libvirt_snapshot_dtor(virt_resource *rsrc
TSRMLS_DC);
PHP_FUNCTION(libvirt_domain_has_current_snapshot);
PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name);
PHP_FUNCTION(libvirt_domain_snapshot_create);
+PHP_FUNCTION(libvirt_domain_snapshot_create_xml);
PHP_FUNCTION(libvirt_domain_snapshot_get_xml);
PHP_FUNCTION(libvirt_domain_snapshot_revert);
PHP_FUNCTION(libvirt_domain_snapshot_delete);
--
2.17.1
Regards,
Zhensheng Yuan
5 years, 9 months
[libvirt] [RFC PATCH] udev: Remove udev handle from main loop when udev thread stops
by Marc Hartmayer
Commit "nodedev: Move device enumumeration out of nodeStateInitialize"
(9f0ae0b18e3e620) has moved the heavy task of device enumeration into
a separate thread. The problem with this commit is that there is a
functionality change in the cleanup when udevEnumerateDevices
fails. Before commit 9f0ae0b18e3e620, the entire driver was cleaned up
by calling nodeStateCleanup (defined in node_device_udev.c) which
resulted in libvirtd stopping with the error message
'daemonRunStateInit:800 : Driver state initialization failed'. With
the commit 9f0ae0b18e3e620 there is only a signal to the udev thread
that it must stop. This means that for example the watch handle isn't
removed from the main loop and this can result in the main loop
consuming 100% CPU time as soon as a new udev event occurs.
This patch proposes a simple solution to the described problem. In
case the udev thread stops the watch handle is removed from the main
loop.
Fixes: 9f0ae0b18e3e620 ("nodedev: Move device enumumeration out of nodeStateInitialize")
Signed-off-by: Marc Hartmayer <mhartmay(a)linux.ibm.com>
---
Note: I'm not sure whether we should stop libvirtd (as it would have
been done before) or if this patch is already sufficient.
---
src/node_device/node_device_udev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index b1e5f00067e8..299f55260129 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1628,6 +1628,13 @@ udevEventHandleThread(void *opaque ATTRIBUTE_UNUSED)
}
if (priv->threadQuit) {
+ if (priv->watch != -1) {
+ /* Since the udev thread getting stopped remove the
+ * watch handle from the main loop */
+ virEventRemoveHandle(priv->watch);
+ priv->watch = -1;
+ }
+
virObjectUnlock(priv);
return;
}
--
2.17.0
5 years, 9 months
[libvirt] [PATCH v2 0/5] virDomainXMLFlags cleanups (incremental backup saga)
by Eric Blake
Since v1: add two new patches (1, 2), improve commit message wording
of patch 4/5 [Dan].
Eric Blake (5):
domain: Fix unknown flags diagnosis in virDomainGetXMLDesc
qemu: Use correct domain xml flag
domain: Document VIR_DOMAIN_XML_MIGRATABLE
domain: Define explicit flags for saved image xml
snapshot: Define explicit flags for snapshot xml
include/libvirt/libvirt-domain-snapshot.h | 4 ++++
include/libvirt/libvirt-domain.h | 5 +++++
src/conf/domain_conf.h | 3 +++
src/bhyve/bhyve_driver.c | 2 ++
src/conf/domain_conf.c | 2 ++
src/esx/esx_driver.c | 2 +-
src/hyperv/hyperv_driver.c | 2 +-
src/libvirt-domain-snapshot.c | 9 ++++-----
src/libvirt-domain.c | 22 +++++++++++++---------
src/libxl/libxl_driver.c | 2 +-
src/lxc/lxc_driver.c | 2 +-
src/openvz/openvz_driver.c | 2 +-
src/phyp/phyp_driver.c | 2 +-
src/qemu/qemu_driver.c | 11 ++++++-----
src/remote/remote_protocol.x | 6 +++---
src/test/test_driver.c | 4 ++--
src/vbox/vbox_common.c | 2 +-
src/vmware/vmware_driver.c | 2 +-
src/vz/vz_driver.c | 4 ++--
19 files changed, 54 insertions(+), 34 deletions(-)
--
2.20.1
5 years, 9 months
[libvirt] [PATCH v2 0/6] dirty-bitmaps: deprecate @status field
by John Snow
The current internal meanings of "locked", "user_locked",
"qmp_locked", "frozen", "enabled", and "disabled" are all
a little muddled.
Deprecate the @status field in favor of two new booleans
that carry very specific meanings. Then, rename and rework
some of the internal semantics to help make the API a bit
more clear and easier to read.
Well, in my opinion.
Based on my current bitmaps branch (includes Eric's patch
and my documentation update patch.)
V2: - All of Eric's suggestions, I hope.
- Vladimir's phrasing suggestion on patch 1
- Added a sixth patch that's mostly just motion.
I'm on PTO the next two days, so I didn't get to writing
a test for the busy bit. I think test 223 is a good candidate,
because it uses the NBD functionality. To test with push mode,
I need to come up with a blockdebug configuration that will
let me pause an incremental backup so I can test race-free.
Maybe for V3, sorry.
John Snow (6):
block/dirty-bitmap: add recording and busy properties
block/dirty-bitmaps: rename frozen predicate helper
block/dirty-bitmap: change semantics of enabled predicate
block/dirty-bitmap: explicitly lock bitmaps with successors
block/dirty-bitmaps: unify qmp_locked and user_locked calls
block/dirty-bitmaps: move comment block
block/dirty-bitmap.c | 110 ++++++++++++++++++---------------
blockdev.c | 18 +++---
include/block/dirty-bitmap.h | 7 +--
migration/block-dirty-bitmap.c | 8 +--
nbd/server.c | 6 +-
qapi/block-core.json | 10 ++-
qemu-deprecated.texi | 6 ++
tests/qemu-iotests/236.out | 28 +++++++++
8 files changed, 122 insertions(+), 71 deletions(-)
--
2.17.2
5 years, 9 months
[libvirt] [PATCH] iohelper: Remove remaining newlines from error messages
by Andrea Bolognani
The iohelper is an internal program that's only supposed to
be called by libvirt, and whatever output it might produce
will ultimately be passed to virReportError() or similar.
Since we do not want strings passed to those functions to
contain newlines, we can simply not output them in the first
place.
This is what happens in pretty much all cases already, but
in a couple instances newlines have managed to slip in.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/util/iohelper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index aed7ef3184..ddc338b7c7 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -181,7 +181,7 @@ usage(int status)
if (status) {
fprintf(stderr, _("%s: try --help for more details"), program_name);
} else {
- printf(_("Usage: %s FILENAME FD\n"), program_name);
+ printf(_("Usage: %s FILENAME FD"), program_name);
}
exit(status);
}
@@ -198,7 +198,7 @@ main(int argc, char **argv)
if (virGettextInitialize() < 0 ||
virThreadInitialize() < 0 ||
virErrorInitialize() < 0) {
- fprintf(stderr, _("%s: initialization failed\n"), program_name);
+ fprintf(stderr, _("%s: initialization failed"), program_name);
exit(EXIT_FAILURE);
}
--
2.20.1
5 years, 9 months