All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Anthony Liguori" <aliguori@us.ibm.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	qemu-devel@nongnu.org, "Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH] pc: cleanup 1.4 compat support
Date: Mon, 19 Aug 2013 16:02:10 +0300	[thread overview]
Message-ID: <20130819130210.GA810@redhat.com> (raw)
In-Reply-To: <20130819120428.GL2631@otherpad.lan.raisama.net>

On Mon, Aug 19, 2013 at 09:04:28AM -0300, Eduardo Habkost wrote:
> On Sun, Aug 18, 2013 at 04:50:02PM +0300, Michael S. Tsirkin wrote:
> > Make 1.4 compat code call the 1.6 one, reducing
> > code duplication. Add comment explaining why we can't
> > make 1.4 call 1.5 as usual.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  hw/i386/pc_piix.c | 4 ++--
> >  hw/i386/pc_q35.c  | 4 ++--
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> > index 15c932e..86cfadc 100644
> > --- a/hw/i386/pc_piix.c
> > +++ b/hw/i386/pc_piix.c
> > @@ -272,8 +272,8 @@ static void pc_init_pci_1_4(QEMUMachineInitArgs *args)
> >  {
> >      x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
> >      x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
> > -    has_pci_info = false;
> > -    pc_init_pci(args);
> > +    /* 1.5 was special - it enabled pvpanic in builtin machine */
> > +    pc_init_pci_1_6(args);
> >  }
> >  
> 
> I find this confusing (and probably it will be even more confusing when
> people read this code a few years from now). I would prefer the
> following pattern:
> 
> static void pc_compat_1_5()
> {
> 	/* do 1.5 stuff (possibly undoing 1.6 stuff) */
> 	has_pvpanic = true;
> }
> 
> static void pc_init_pci_1_5()
> {
> 	pc_compat_1_5();
> 	pc_init_pci();
> }
> 
> static void pc_compat_1_4()
> {
> 	pc_compat_1_5();
> 	/* do 1.4 stuff (possibly undoing 1.5 stuff) */
> 	has_pvpanic = false;
> }
> 
> static void pc_init_pci_1_4()
> {
> 	pc_compat_1_4();
> 	pc_init_pci();
> }
> 
> static void pc_compat_1_3()
> {
> 	pc_compat_1_3();
> 	/* do 1.3 stuff (possibly undoing 1.4 stuff) */
> }
> 
> static void pc_init_pci_1_3()
> {
> 	pc_compat_1_3();
> 	pc_init_pci();
> }
> 
> Otherwise the same problem may happen again in the future.

Sure, why not. Want to send a patch like this?
Prefer a patch on top of this one, or instead of it?

> 
> With this, we could even reuse the same pc_compat_*() functions on
> pc_piix.c and pc_q35.c.

That would be nice.

> >  static void pc_init_pci_1_3(QEMUMachineInitArgs *args)
> > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> > index 09d8183..8d62700 100644
> > --- a/hw/i386/pc_q35.c
> > +++ b/hw/i386/pc_q35.c
> > @@ -239,8 +239,8 @@ static void pc_q35_init_1_4(QEMUMachineInitArgs *args)
> >  {
> >      x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
> >      x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
> > -    has_pci_info = false;
> > -    pc_q35_init(args);
> > +    /* 1.5 was special - it enabled pvpanic in builtin machine */
> > +    pc_q35_init_1_6(args);
> >  }
> >  
> >  static QEMUMachine pc_q35_machine_v1_6 = {
> > -- 
> > MST
> 
> -- 
> Eduardo

  reply	other threads:[~2013-08-19 18:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-18 13:50 [Qemu-devel] [PATCH] pc: cleanup 1.4 compat support Michael S. Tsirkin
2013-08-18 14:17 ` Andreas Färber
2013-08-19 12:04 ` Eduardo Habkost
2013-08-19 13:02   ` Michael S. Tsirkin [this message]
2013-08-19 14:19     ` Eduardo Habkost
2013-08-19 14:28       ` Michael S. Tsirkin
2013-08-19 14:52         ` Eduardo Habkost

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=20130819130210.GA810@redhat.com \
    --to=mst@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=ehabkost@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.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 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.