qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Lin Ma" <lma@suse.com>
Cc: QEMU <qemu-devel@nongnu.org>, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [PATCH v3] qga: Correct loop count in qmp_guest_get_vcpus()
Date: Tue, 24 Nov 2020 15:11:23 +0100	[thread overview]
Message-ID: <ec802fc0-d348-6206-5cdd-20f28294d9a8@redhat.com> (raw)
In-Reply-To: <CAJ+F1CLuY7XtvpJXRfkK5dBpi3ZU5VYcmJ9XndP0S8CLQ1uXPw@mail.gmail.com>

Hi,

On 11/20/20 1:33 PM, Marc-André Lureau wrote:
> Hi
> 
> On Fri, Nov 20, 2020 at 4:27 PM Lin Ma <lma@suse.com
> <mailto:lma@suse.com>> wrote:
> 
>     The guest-get-vcpus returns incorrect vcpu info in case we hotunplug
>     vcpus(not
>     the last one).
>     e.g.:
>     A VM has 4 VCPUs: cpu0 + 3 hotunpluggable online vcpus(cpu1, cpu2
>     and cpu3).
>     Hotunplug cpu2,  Now only cpu0, cpu1 and cpu3 are present & online.
> 
>     ./qmp-shell /tmp/qmp-monitor.sock
>     (QEMU) query-hotpluggable-cpus
>     {"return": [
>     {"props": {"core-id": 0, "thread-id": 0, "socket-id": 3},
>     "vcpus-count": 1,
>      "qom-path": "/machine/peripheral/cpu3", "type": "host-x86_64-cpu"},
>     {"props": {"core-id": 0, "thread-id": 0, "socket-id": 2},
>     "vcpus-count": 1,
>      "qom-path": "/machine/peripheral/cpu2", "type": "host-x86_64-cpu"},
>     {"props": {"core-id": 0, "thread-id": 0, "socket-id": 1},
>     "vcpus-count": 1,
>      "qom-path": "/machine/peripheral/cpu1", "type": "host-x86_64-cpu"},
>     {"props": {"core-id": 0, "thread-id": 0, "socket-id": 0},
>     "vcpus-count": 1,
>      "qom-path": "/machine/unattached/device[0]", "type": "host-x86_64-cpu"}
>     ]}
> 
>     (QEMU) device_del id=cpu2
>     {"return": {}}
> 
>     (QEMU) query-hotpluggable-cpus
>     {"return": [
>     {"props": {"core-id": 0, "thread-id": 0, "socket-id": 3},
>     "vcpus-count": 1,
>      "qom-path": "/machine/peripheral/cpu3", "type": "host-x86_64-cpu"},
>     {"props": {"core-id": 0, "thread-id": 0, "socket-id": 2},
>     "vcpus-count": 1,
>      "type": "host-x86_64-cpu"},
>     {"props": {"core-id": 0, "thread-id": 0, "socket-id": 1},
>     "vcpus-count": 1,
>      "qom-path": "/machine/peripheral/cpu1", "type": "host-x86_64-cpu"},
>     {"props": {"core-id": 0, "thread-id": 0, "socket-id": 0},
>     "vcpus-count": 1,
>      "qom-path": "/machine/unattached/device[0]", "type": "host-x86_64-cpu"}
>     ]}
> 
>     Before:
>     ./qmp-shell -N /tmp/qmp-ga.sock
>     Welcome to the QMP low-level shell!
>     Connected
>     (QEMU) guest-get-vcpus
>     {"return": [
>     {"online": true, "can-offline": false, "logical-id": 0},
>     {"online": true, "can-offline": true, "logical-id": 1}]}
> 
>     After:
>     ./qmp-shell -N /tmp/qmp-ga.sock
>     Welcome to the QMP low-level shell!
>     Connected
>     (QEMU) guest-get-vcpus
>     {"return": [
>     {"online": true, "can-offline": false, "logical-id": 0},
>     {"online": true, "can-offline": true, "logical-id": 1},
>     {"online": true, "can-offline": true, "logical-id": 3}]}
> 
>     Signed-off-by: Lin Ma <lma@suse.com <mailto:lma@suse.com>>
>     ---
>      qga/commands-posix.c | 45 ++++++++++++++++----------------------------
>      1 file changed, 16 insertions(+), 29 deletions(-)
> 
>     diff --git a/qga/commands-posix.c b/qga/commands-posix.c
>     index c089e38120..ee05e694d3 100644
>     --- a/qga/commands-posix.c
>     +++ b/qga/commands-posix.c
>     @@ -2376,24 +2376,6 @@ error:
>          return NULL;
>      }
> 
>     -#define SYSCONF_EXACT(name, errp) sysconf_exact((name), #name, (errp))
>     -
>     -static long sysconf_exact(int name, const char *name_str, Error **errp)
>     -{
>     -    long ret;
>     -
>     -    errno = 0;
>     -    ret = sysconf(name);
>     -    if (ret == -1) {
>     -        if (errno == 0) {
>     -            error_setg(errp, "sysconf(%s): value indefinite",
>     name_str);
>     -        } else {
>     -            error_setg_errno(errp, errno, "sysconf(%s)", name_str);
>     -        }
>     -    }
>     -    return ret;
>     -}
>     -
>      /* Transfer online/offline status between @vcpu and the guest system.
>       *
>       * On input either @errp or *@errp must be NULL.
>     @@ -2464,24 +2446,29 @@ static void
>     transfer_vcpu(GuestLogicalProcessor *vcpu, bool sys2vcpu,
> 
>      GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
>      {
>     -    int64_t current;
>          GuestLogicalProcessorList *head, **link;
>     -    long sc_max;
>     +    g_autofree char *cpu_dir = NULL;
>     +    const gchar *line;
>     +    GDir *cpu_gdir = NULL;
>          Error *local_err = NULL;
> 
>     -    current = 0;
>          head = NULL;
>          link = &head;
>     -    sc_max = SYSCONF_EXACT(_SC_NPROCESSORS_CONF, &local_err);
>     +    cpu_dir = g_strdup_printf("/sys/devices/system/cpu");
> 
> 
> Why strdup?

As we are going to tag 5.2-rc3, what is the status of this fix?

Thanks,

Phil.



  reply	other threads:[~2020-11-24 14:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20 12:27 [PATCH v3] qga: Correct loop count in qmp_guest_get_vcpus() Lin Ma
2020-11-20 12:33 ` Marc-André Lureau
2020-11-24 14:11   ` Philippe Mathieu-Daudé [this message]
2020-11-24 22:05     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ec802fc0-d348-6206-5cdd-20f28294d9a8@redhat.com \
    --to=philmd@redhat.com \
    --cc=lma@suse.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).