[libvirt] [PATCH] fix 1 << -1 at JOB_MASK macro

From: caoxinhua <caoxinhua@huawei.com> when we start a vm, we call JOB_MASK(QEMU_JOB_NONE), then 1 << -1 will be execute. we fix it as return 0 --- src/libxl/libxl_domain.h | 2 +- src/qemu/qemu_domain.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h index 3a3890b..dc40139 100644 --- a/src/libxl/libxl_domain.h +++ b/src/libxl/libxl_domain.h @@ -30,7 +30,7 @@ # include "libxl_conf.h" # include "virchrdev.h" -# define JOB_MASK(job) (1 << (job - 1)) +# define JOB_MASK(job) (job == 0 ? 0 : 1 << (job - 1)) # define DEFAULT_JOB_MASK \ (JOB_MASK(LIBXL_JOB_DESTROY) | \ JOB_MASK(LIBXL_JOB_ABORT)) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 365b23c..6750215 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -51,7 +51,7 @@ # define QEMU_DOMAIN_MIG_BANDWIDTH_MAX (INT64_MAX / (1024 * 1024)) # endif -# define JOB_MASK(job) (1 << (job - 1)) +# define JOB_MASK(job) (job == 0 ? 0 : 1 << (job - 1)) # define QEMU_JOB_DEFAULT_MASK \ (JOB_MASK(QEMU_JOB_QUERY) | \ JOB_MASK(QEMU_JOB_DESTROY) | \ -- 2.8.3

On Sat, Jul 15, 2017 at 14:42:39 +0800, xinhua.Cao wrote:
From: caoxinhua <caoxinhua@huawei.com>
when we start a vm, we call JOB_MASK(QEMU_JOB_NONE), then 1 << -1 will be execute. we fix it as return 0 --- src/libxl/libxl_domain.h | 2 +- src/qemu/qemu_domain.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
[....]
index 365b23c..6750215 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -51,7 +51,7 @@ # define QEMU_DOMAIN_MIG_BANDWIDTH_MAX (INT64_MAX / (1024 * 1024)) # endif
-# define JOB_MASK(job) (1 << (job - 1)) +# define JOB_MASK(job) (job == 0 ? 0 : 1 << (job - 1))
This makes QEMU_JOB_NONE and QEMU_JOB_QUERY to have the same result. I think you need to fix some other place. What is the problem you are seeing?

-----邮件原件----- 发件人: Peter Krempa [mailto:pkrempa@redhat.com] 发送时间: 2017年7月17日 18:15 收件人: Caoxinhua 抄送: libvir-list@redhat.com; jferlan@redhat.com; Yanqiangjun; Huangweidong (C); weifuqiang 主题: Re: [libvirt] [PATCH] fix 1 << -1 at JOB_MASK macro On Sat, Jul 15, 2017 at 14:42:39 +0800, xinhua.Cao wrote:
From: caoxinhua <caoxinhua@huawei.com>
when we start a vm, we call JOB_MASK(QEMU_JOB_NONE), then 1 << -1 will be execute. we fix it as return 0 --- src/libxl/libxl_domain.h | 2 +- src/qemu/qemu_domain.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
[....]
index 365b23c..6750215 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -51,7 +51,7 @@ # define QEMU_DOMAIN_MIG_BANDWIDTH_MAX (INT64_MAX / (1024 * 1024)) # endif
-# define JOB_MASK(job) (1 << (job - 1)) +# define JOB_MASK(job) (job == 0 ? 0 : 1 << (job - 1))
This makes QEMU_JOB_NONE and QEMU_JOB_QUERY to have the same result. I think you need to fix some other place. What is the problem you are seeing?

1、JOB_MASK(QEMU_JOB_NONE) = 0; JOB_MASK(QEMU_JOB_QUERY) = 1; 2、It isn't a question, but it looked awkward. -----邮件原件----- 发件人: Peter Krempa [mailto:pkrempa@redhat.com] 发送时间: 2017年7月17日 18:15 收件人: Caoxinhua 抄送: libvir-list@redhat.com; jferlan@redhat.com; Yanqiangjun; Huangweidong (C); weifuqiang 主题: Re: [libvirt] [PATCH] fix 1 << -1 at JOB_MASK macro On Sat, Jul 15, 2017 at 14:42:39 +0800, xinhua.Cao wrote:
From: caoxinhua <caoxinhua@huawei.com>
when we start a vm, we call JOB_MASK(QEMU_JOB_NONE), then 1 << -1 will be execute. we fix it as return 0 --- src/libxl/libxl_domain.h | 2 +- src/qemu/qemu_domain.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
[....]
index 365b23c..6750215 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -51,7 +51,7 @@ # define QEMU_DOMAIN_MIG_BANDWIDTH_MAX (INT64_MAX / (1024 * 1024)) # endif
-# define JOB_MASK(job) (1 << (job - 1)) +# define JOB_MASK(job) (job == 0 ? 0 : 1 << (job - 1))
This makes QEMU_JOB_NONE and QEMU_JOB_QUERY to have the same result. I think you need to fix some other place. What is the problem you are seeing?

On Sat, Jul 15, 2017 at 14:42:39 +0800, xinhua.Cao wrote:
From: caoxinhua <caoxinhua@huawei.com>
when we start a vm, we call JOB_MASK(QEMU_JOB_NONE), then 1 << -1 will be execute. we fix it as return 0
Could you point us to the place in our code where JOB_MASK is called on QEMU_JOB_NONE? Jirka

When we start a vm, we call JOB_MASK(QEMU_JOB_NONE) at follow backtrace Breakpoint 1, qemuDomainObjPrivateXMLFormat (buf=0x7f8078fcd510, vm=0x7f808c2c7d70) at qemu/qemu_domain.c:1779 1779 if (!qemuDomainTrackJob(job)) (gdb) p job $1 = QEMU_JOB_NONE (gdb) bt #0 qemuDomainObjPrivateXMLFormat (buf=0x7f8078fcd510, vm=0x7f808c2c7d70) at qemu/qemu_domain.c:1779 #1 0x00007f80899e7988 in virDomainObjFormat (xmlopt=0x7f808c275c60, obj=obj@entry=0x7f808c2c7d70, caps=0x7f808c25b450, flags=flags@entry=625) at conf/domain_conf.c:24936 #2 0x00007f80899e7a5c in virDomainSaveStatus (xmlopt=<optimized out>, statusDir=0x7f808c28de30 "/var/run/libvirt/qemu", obj=obj@entry=0x7f808c2c7d70, caps=<optimized out>) at conf/domain_conf.c:25149 #3 0x00007f806f7d8840 in qemuProcessLaunch (conn=conn@entry=0x7f805c0047c0, driver=driver@entry=0x7f808c2d1530, vm=vm@entry=0x7f808c2c7d70, asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_START, incoming=incoming@entry=0x0, snapshot=snapshot@entry=0x0, vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=flags@entry=17) at qemu/qemu_process.c:5757 this is not a problem, just looks very awkward. -----邮件原件----- 发件人: Jiri Denemark [mailto:jdenemar@redhat.com] 发送时间: 2017年7月17日 21:31 收件人: Caoxinhua 抄送: libvir-list@redhat.com; jferlan@redhat.com; Yanqiangjun; Huangweidong (C); weifuqiang 主题: Re: [libvirt] [PATCH] fix 1 << -1 at JOB_MASK macro On Sat, Jul 15, 2017 at 14:42:39 +0800, xinhua.Cao wrote:
From: caoxinhua <caoxinhua@huawei.com>
when we start a vm, we call JOB_MASK(QEMU_JOB_NONE), then 1 << -1 will be execute. we fix it as return 0
Could you point us to the place in our code where JOB_MASK is called on QEMU_JOB_NONE? Jirka

On Tue, Jul 18, 2017 at 02:04:27 +0000, Caoxinhua wrote:
When we start a vm, we call JOB_MASK(QEMU_JOB_NONE) at follow backtrace
Breakpoint 1, qemuDomainObjPrivateXMLFormat (buf=0x7f8078fcd510, vm=0x7f808c2c7d70) at qemu/qemu_domain.c:1779 1779 if (!qemuDomainTrackJob(job)) (gdb) p job $1 = QEMU_JOB_NONE (gdb) bt #0 qemuDomainObjPrivateXMLFormat (buf=0x7f8078fcd510, vm=0x7f808c2c7d70) at qemu/qemu_domain.c:1779 #1 0x00007f80899e7988 in virDomainObjFormat (xmlopt=0x7f808c275c60, obj=obj@entry=0x7f808c2c7d70, caps=0x7f808c25b450, flags=flags@entry=625) at conf/domain_conf.c:24936 #2 0x00007f80899e7a5c in virDomainSaveStatus (xmlopt=<optimized out>, statusDir=0x7f808c28de30 "/var/run/libvirt/qemu", obj=obj@entry=0x7f808c2c7d70, caps=<optimized out>) at conf/domain_conf.c:25149 #3 0x00007f806f7d8840 in qemuProcessLaunch (conn=conn@entry=0x7f805c0047c0, driver=driver@entry=0x7f808c2d1530, vm=vm@entry=0x7f808c2c7d70, asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_START, incoming=incoming@entry=0x0, snapshot=snapshot@entry=0x0, vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=flags@entry=17) at qemu/qemu_process.c:5757
Yes, you're right. ACK to the patch. Jirka
participants (4)
-
Caoxinhua
-
Jiri Denemark
-
Peter Krempa
-
xinhua.Cao