All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: linux-kernel@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org,
	john cooper <john.cooper@redhat.com>
Subject: [PATCH 2/4] lguest: get rid of offset hack in example launcher
Date: Wed, 30 Sep 2009 02:48:23 +0930	[thread overview]
Message-ID: <200909300248.24355.rusty@rustcorp.com.au> (raw)


We never supported the ATA VIRTIO_BLK_F_IDENTIFY anyway, but simply
including it in the struct definition broke us (see commit 8ef562d112
"lguest: fix descriptor corruption in example launcher").

Now we can acknowledge that it's deprecated, and get the struct without it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 Documentation/lguest/lguest.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -6,6 +6,7 @@
 :*/
 #define _LARGEFILE64_SOURCE
 #define _GNU_SOURCE
+#define VIRTIO_BLK_IDENTIFY_DEPRECATED
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -1750,8 +1751,21 @@ static void setup_block_file(const char 
 	add_feature(dev, VIRTIO_BLK_F_SEG_MAX);
 	conf.seg_max = cpu_to_le32(VIRTQUEUE_NUM - 2);
 
-	/* Don't try to put whole struct: we have 8 bit limit. */
-	set_config(dev, offsetof(struct virtio_blk_config, geometry), &conf);
+	/*
+	 * We only have 8 bits of configuration space for each device.  But a
+	 * new feature for virtio_blk added a 1k 'identify' field to struct
+	 * virtio_blk_config.  We figured that this was a bad idea, but too
+	 * late: the code was already in the wild.
+	 *
+	 * Normally, new features get added to the end of the config struct,
+	 * but that won't do in this case.  So now, if you define
+	 * VIRTIO_BLK_IDENTIFY_DEPRECATED (as we do at the top of this file),
+	 * it pretends that field doesn't exist at all, and we can add new ones
+	 * where it once was.
+	 *
+	 * This way, old code still compiles.  Bit of a mess, though.
+	 */
+	set_config(dev, sizeof(struct virtio_blk_config), &conf);
 
 	verbose("device %u: virtblock %llu sectors\n",
 		++devices.device_num, le64_to_cpu(conf.capacity));


             reply	other threads:[~2009-09-29 17:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-29 17:18 Rusty Russell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-09-29 17:18 [PATCH 2/4] lguest: get rid of offset hack in example launcher Rusty Russell

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=200909300248.24355.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=john.cooper@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.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.