Re: [PATCH v3 1/3] test_driver: Implement virDomainGetMessages

2021-07-12 Thread Martin Kletzander

On Mon, Jul 12, 2021 at 11:16:50AM +0800, Luke Yue wrote:

On Fri, 2021-07-09 at 15:10 +0200, Martin Kletzander wrote:

On Wed, Jun 30, 2021 at 10:53:44AM +0800, Luke Yue wrote:
> Signed-off-by: Luke Yue 
> ---
> src/test/test_driver.c | 53
> ++
> 1 file changed, 53 insertions(+)
>

If you first abstract the code from qemu driver then there's less
code
move to add this functionality.  Also one more thing to check is
whether
qemu driver is the only one that has this code and that it is not
duplicated anywhere else - we could dedup even more code ;)


Thanks! But I'm sorry that I find out that qemu driver seems to be the
only one that has this code (what I extracted to
virDomainObjGetMessages), do I miss something? Or it's just a general
suggestion for future development work?



Just a general suggestion.  I did not know whether qemu driver is the only one
that has this code or not, but since you checked you already did what I
suggested ;)  I'd still switch it around and first abstract the qemu code and
then implement the test driver one.


signature.asc
Description: PGP signature


Re: [PATCH v3 1/3] test_driver: Implement virDomainGetMessages

2021-07-11 Thread Luke Yue
On Fri, 2021-07-09 at 15:10 +0200, Martin Kletzander wrote:
> On Wed, Jun 30, 2021 at 10:53:44AM +0800, Luke Yue wrote:
> > Signed-off-by: Luke Yue 
> > ---
> > src/test/test_driver.c | 53
> > ++
> > 1 file changed, 53 insertions(+)
> > 
> 
> If you first abstract the code from qemu driver then there's less
> code
> move to add this functionality.  Also one more thing to check is
> whether
> qemu driver is the only one that has this code and that it is not
> duplicated anywhere else - we could dedup even more code ;)

Thanks! But I'm sorry that I find out that qemu driver seems to be the
only one that has this code (what I extracted to
virDomainObjGetMessages), do I miss something? Or it's just a general
suggestion for future development work? 



Re: [PATCH v3 1/3] test_driver: Implement virDomainGetMessages

2021-07-09 Thread Martin Kletzander

On Wed, Jun 30, 2021 at 10:53:44AM +0800, Luke Yue wrote:

Signed-off-by: Luke Yue 
---
src/test/test_driver.c | 53 ++
1 file changed, 53 insertions(+)



If you first abstract the code from qemu driver then there's less code
move to add this functionality.  Also one more thing to check is whether
qemu driver is the only one that has this code and that it is not
duplicated anywhere else - we could dedup even more code ;)


signature.asc
Description: PGP signature


[PATCH v3 1/3] test_driver: Implement virDomainGetMessages

2021-06-29 Thread Luke Yue
Signed-off-by: Luke Yue 
---
 src/test/test_driver.c | 53 ++
 1 file changed, 53 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ef0ddab54d..35742fcde3 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -9291,6 +9291,58 @@ testDomainCheckpointDelete(virDomainCheckpointPtr 
checkpoint,
 return ret;
 }
 
+static int
+testDomainGetMessages(virDomainPtr dom,
+  char ***msgs,
+  unsigned int flags)
+{
+virDomainObj *vm = NULL;
+int rv = -1;
+size_t i, n;
+int nmsgs;
+
+virCheckFlags(VIR_DOMAIN_MESSAGE_DEPRECATION |
+  VIR_DOMAIN_MESSAGE_TAINTING, -1);
+
+if (!(vm = testDomObjFromDomain(dom)))
+return -1;
+
+*msgs = NULL;
+nmsgs = 0;
+n = 0;
+
+if (!flags || (flags & VIR_DOMAIN_MESSAGE_TAINTING)) {
+nmsgs += __builtin_popcount(vm->taint);
+*msgs = g_renew(char *, *msgs, nmsgs+1);
+
+for (i = 0; i < VIR_DOMAIN_TAINT_LAST; i++) {
+if (vm->taint & (1 << i)) {
+(*msgs)[n++] = g_strdup_printf(
+_("tainted: %s"),
+_(virDomainTaintMessageTypeToString(i)));
+}
+}
+}
+
+if (!flags || (flags & VIR_DOMAIN_MESSAGE_DEPRECATION)) {
+nmsgs += vm->ndeprecations;
+*msgs = g_renew(char *, *msgs, nmsgs+1);
+
+for (i = 0; i < vm->ndeprecations; i++) {
+(*msgs)[n++] = g_strdup_printf(
+_("deprecated configuration: %s"),
+vm->deprecations[i]);
+}
+}
+
+(*msgs)[nmsgs] = NULL;
+
+rv = nmsgs;
+
+virDomainObjEndAPI();
+return rv;
+}
+
 /*
  * Test driver
  */
@@ -9448,6 +9500,7 @@ static virHypervisorDriver testHypervisorDriver = {
 .domainCheckpointLookupByName = testDomainCheckpointLookupByName, /* 5.6.0 
*/
 .domainCheckpointGetParent = testDomainCheckpointGetParent, /* 5.6.0 */
 .domainCheckpointDelete = testDomainCheckpointDelete, /* 5.6.0 */
+.domainGetMessages = testDomainGetMessages, /* 7.6.0 */
 };
 
 static virNetworkDriver testNetworkDriver = {
-- 
2.32.0