All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Like Xu <like.xu@linux.intel.com>
Cc: qemu-trivial@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	like.xu@intel.com, qemu-devel@nongnu.org,
	Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v3 1/2] vl.c: refactor current_machine as non-global variable
Date: Wed, 17 Apr 2019 07:26:14 +0200	[thread overview]
Message-ID: <87bm1519u1.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <1555315185-16414-2-git-send-email-like.xu@linux.intel.com> (Like Xu's message of "Mon, 15 Apr 2019 15:59:44 +0800")

Like Xu <like.xu@linux.intel.com> writes:

> This patch makes the remaining dozen or so uses of the global
> current_machine outside vl.c use qdev_get_machine() instead,
> and then make current_machine local to vl.c instead of global.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Like Xu <like.xu@linux.intel.com>

I'm afraid I dislike this one, too.

The patch does not reduce global state, it's merely MICAHI (make it
complicated and hide it).

It does not improve safety, it merely turns dereferences of null
current_machine into unwanted creation of "/machine" as container (ugh),
which the next patch then fixes up to assertion failure.

The only benefit I can see is you can't assign to current_machine
outside vl.c anymore.  Nobody ever did, thus complete non-issue.

If you want to hide global state without actually reducing it, create an
accessor function.  You can then use that to replace qdev_get_machine(),
getting rid of its surprising side effect.  *That* would be an
improvement I could get behind.

Better that *hiding* use of global state would be *eliminating* use of
global state: pass current_machine around.  This isn't always practical.
But where it is, the dependence on "machine created" becomes obvious in
the code.


WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: Like Xu <like.xu@linux.intel.com>
Cc: qemu-trivial@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	like.xu@intel.com, qemu-devel@nongnu.org,
	Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 1/2] vl.c: refactor current_machine as non-global variable
Date: Wed, 17 Apr 2019 07:26:14 +0200	[thread overview]
Message-ID: <87bm1519u1.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <1555315185-16414-2-git-send-email-like.xu@linux.intel.com> (Like Xu's message of "Mon, 15 Apr 2019 15:59:44 +0800")

Like Xu <like.xu@linux.intel.com> writes:

> This patch makes the remaining dozen or so uses of the global
> current_machine outside vl.c use qdev_get_machine() instead,
> and then make current_machine local to vl.c instead of global.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Like Xu <like.xu@linux.intel.com>

I'm afraid I dislike this one, too.

The patch does not reduce global state, it's merely MICAHI (make it
complicated and hide it).

It does not improve safety, it merely turns dereferences of null
current_machine into unwanted creation of "/machine" as container (ugh),
which the next patch then fixes up to assertion failure.

The only benefit I can see is you can't assign to current_machine
outside vl.c anymore.  Nobody ever did, thus complete non-issue.

If you want to hide global state without actually reducing it, create an
accessor function.  You can then use that to replace qdev_get_machine(),
getting rid of its surprising side effect.  *That* would be an
improvement I could get behind.

Better that *hiding* use of global state would be *eliminating* use of
global state: pass current_machine around.  This isn't always practical.
But where it is, the dependence on "machine created" becomes obvious in
the code.

WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: Like Xu <like.xu@linux.intel.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
	like.xu@intel.com, Igor Mammedov <imammedo@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 1/2] vl.c: refactor current_machine as non-global variable
Date: Wed, 17 Apr 2019 07:26:14 +0200	[thread overview]
Message-ID: <87bm1519u1.fsf@dusky.pond.sub.org> (raw)
Message-ID: <20190417052614.QgDZJdUBs7XakLFu3mlx8AYstCUvaMybTHHvYMWDG6s@z> (raw)
In-Reply-To: <1555315185-16414-2-git-send-email-like.xu@linux.intel.com> (Like Xu's message of "Mon, 15 Apr 2019 15:59:44 +0800")

Like Xu <like.xu@linux.intel.com> writes:

> This patch makes the remaining dozen or so uses of the global
> current_machine outside vl.c use qdev_get_machine() instead,
> and then make current_machine local to vl.c instead of global.
>
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Like Xu <like.xu@linux.intel.com>

I'm afraid I dislike this one, too.

The patch does not reduce global state, it's merely MICAHI (make it
complicated and hide it).

It does not improve safety, it merely turns dereferences of null
current_machine into unwanted creation of "/machine" as container (ugh),
which the next patch then fixes up to assertion failure.

The only benefit I can see is you can't assign to current_machine
outside vl.c anymore.  Nobody ever did, thus complete non-issue.

If you want to hide global state without actually reducing it, create an
accessor function.  You can then use that to replace qdev_get_machine(),
getting rid of its surprising side effect.  *That* would be an
improvement I could get behind.

Better that *hiding* use of global state would be *eliminating* use of
global state: pass current_machine around.  This isn't always practical.
But where it is, the dependence on "machine created" becomes obvious in
the code.


  parent reply	other threads:[~2019-04-17  5:26 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-15  7:59 [Qemu-trivial] [Qemu-devel] [PATCH v3 0/2] vl.c: make current_machine as non-global variable Like Xu
2019-04-15  7:59 ` Like Xu
2019-04-15  7:59 ` Like Xu
2019-04-15  7:59 ` [Qemu-trivial] [Qemu-devel] [PATCH v3 1/2] vl.c: refactor " Like Xu
2019-04-15  7:59   ` Like Xu
2019-04-15  7:59   ` Like Xu
2019-04-16 21:16   ` [Qemu-trivial] " Eduardo Habkost
2019-04-16 21:16     ` Eduardo Habkost
2019-04-16 21:16     ` Eduardo Habkost
2019-04-17  5:26   ` Markus Armbruster [this message]
2019-04-17  5:26     ` Markus Armbruster
2019-04-17  5:26     ` Markus Armbruster
2019-04-17 17:05     ` [Qemu-trivial] " Eduardo Habkost
2019-04-17 17:05       ` Eduardo Habkost
2019-04-17 17:05       ` Eduardo Habkost
2019-04-15  7:59 ` [Qemu-trivial] [Qemu-devel] [PATCH v3 2/2] core/qdev: refactor qdev_get_machine() with type assertion Like Xu
2019-04-15  7:59   ` Like Xu
2019-04-15  7:59   ` Like Xu
2019-04-16 21:20   ` [Qemu-trivial] " Eduardo Habkost
2019-04-16 21:20     ` Eduardo Habkost
2019-04-16 21:20     ` Eduardo Habkost
2019-04-17  5:14     ` [Qemu-trivial] " Markus Armbruster
2019-04-17  5:14       ` Markus Armbruster
2019-04-17  5:14       ` Markus Armbruster
2019-04-17 17:10       ` [Qemu-trivial] " Eduardo Habkost
2019-04-17 17:10         ` Eduardo Habkost
2019-04-17 17:10         ` Eduardo Habkost
2019-04-23  7:59         ` [Qemu-trivial] " Like Xu
2019-04-23  7:59           ` Like Xu
2019-04-24 17:21           ` [Qemu-trivial] " Eduardo Habkost
2019-04-24 17:21             ` Eduardo Habkost
2019-04-24 17:21             ` Eduardo Habkost
2019-04-25  3:12             ` [Qemu-trivial] " Like Xu
2019-04-25  3:12               ` Like Xu
2019-04-25 17:48               ` [Qemu-trivial] " Eduardo Habkost
2019-04-25 17:48                 ` Eduardo Habkost
2019-05-06 11:17                 ` [Qemu-trivial] " Markus Armbruster
2019-05-06 11:17                   ` Markus Armbruster
2019-05-06 11:15           ` [Qemu-trivial] " Markus Armbruster
2019-05-06 11:15             ` Markus Armbruster

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=87bm1519u1.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=like.xu@intel.com \
    --cc=like.xu@linux.intel.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.