qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 16/45] scsi-disk: Track tray locked state


From: Hannes Reinecke
Subject: Re: [Qemu-devel] [PATCH v2 16/45] scsi-disk: Track tray locked state
Date: Thu, 04 Aug 2011 08:46:50 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8

On 08/04/2011 08:39 AM, Markus Armbruster wrote:
Hannes Reinecke<address@hidden>  writes:

On 08/03/2011 03:07 PM, Markus Armbruster wrote:
We already track it in BlockDriverState.  Just like tray open/close
state, we should track it in the device models instead, because it's
device state.

Signed-off-by: Markus Armbruster<address@hidden>
---
   hw/scsi-disk.c |    4 +++-
   1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index db72b86..8ca69f2 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -73,6 +73,7 @@ struct SCSIDiskState
       char *serial;
       SCSISense sense;
       bool tray_open;
+    bool tray_locked;
   };

Hmm. Shouldn't we use a more generic 'flags' here and have bits for
the individual tray states?
Feels like a waste to have individual values here.

On my system, struct SCSIDiskState is 248 bytes before my series (5
bytes of padding at the end), and 248 bytes after (3 bytes padding).  We
use one per disk.

I dare say switching to flags won't make a noticable difference in
memory use ;)

The bool members are easy to read and hard to screw up.

Flags can be nicer when you manipulate several of them together.

Well, but this just proves my point.
Each 'bool' variable takes up one byte, of which only one bit is used. Which qualifies as a waste of space. But if that's okay with everyone and the general consensus on how to code flags in qemu, I'll shut up.

Cheers,

Hannes
--
Dr. Hannes Reinecke                   zSeries & Storage
address@hidden                        +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]