Re: [libvirt] [resend] fix libvirt alignment on arm platforms

2013-12-12 Thread Eric Blake
On 12/12/2013 10:05 AM, Michele Paolino wrote:
> With the changes added by the latest commits (e.g.
> 8a29ffcf9aee45b61a0a12ee45c656cfd52333e8) related to "new events feature
> v2",
> we are unable to compile libvirt on ARM target (OMAP5).
> The error is due to alignment:
> conf/domain_event.c: In function 'virDomainEventDispatchDefaultFunc':
> conf/domain_event.c:1198:30: error: cast increases required alignment of
> target type [-Werror=cast-align]
> conf/domain_event.c:1314:34: error: cast increases required alignment of
> target type [-Werror=cast-align]
> cc1: all warnings being treated as errors
> 
> Using ATTRIBUTE_PACKED we force a structure to not follow architecture and
> compiler best alignments.

NACK; I'd rather go with the union approach, because ATTRIBUTE_PACKED
risks putting things on non-clean boundaries which may then interfere
with attempts to do atomic operations on fields that a subclass may add.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [resend] fix libvirt alignment on arm platforms

2013-12-12 Thread Michele Paolino
With the changes added by the latest commits (e.g.
8a29ffcf9aee45b61a0a12ee45c656cfd52333e8) related to "new events feature
v2",
we are unable to compile libvirt on ARM target (OMAP5).
The error is due to alignment:
conf/domain_event.c: In function 'virDomainEventDispatchDefaultFunc':
conf/domain_event.c:1198:30: error: cast increases required alignment of
target type [-Werror=cast-align]
conf/domain_event.c:1314:34: error: cast increases required alignment of
target type [-Werror=cast-align]
cc1: all warnings being treated as errors

Using ATTRIBUTE_PACKED we force a structure to not follow architecture and
compiler best alignments.
---
 src/conf/domain_event.c |   20 ++--
 src/conf/network_event.c|2 +-
 src/conf/object_event_private.h |2 +-
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 64035f7..7d58367 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -76,7 +76,7 @@ struct _virDomainEventLifecycle {
 
 int type;
 int detail;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventLifecycle virDomainEventLifecycle;
 typedef virDomainEventLifecycle *virDomainEventLifecyclePtr;
 
@@ -84,7 +84,7 @@ struct _virDomainEventRTCChange {
 virDomainEvent parent;
 
 long long offset;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventRTCChange virDomainEventRTCChange;
 typedef virDomainEventRTCChange *virDomainEventRTCChangePtr;
 
@@ -92,7 +92,7 @@ struct _virDomainEventWatchdog {
 virDomainEvent parent;
 
 int action;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventWatchdog virDomainEventWatchdog;
 typedef virDomainEventWatchdog *virDomainEventWatchdogPtr;
 
@@ -103,7 +103,7 @@ struct _virDomainEventIOError {
 char *devAlias;
 int action;
 char *reason;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventIOError virDomainEventIOError;
 typedef virDomainEventIOError *virDomainEventIOErrorPtr;
 
@@ -113,7 +113,7 @@ struct _virDomainEventBlockJob {
 char *path;
 int type;
 int status;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventBlockJob virDomainEventBlockJob;
 typedef virDomainEventBlockJob *virDomainEventBlockJobPtr;
 
@@ -125,7 +125,7 @@ struct _virDomainEventGraphics {
 virDomainEventGraphicsAddressPtr remote;
 char *authScheme;
 virDomainEventGraphicsSubjectPtr subject;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventGraphics virDomainEventGraphics;
 typedef virDomainEventGraphics *virDomainEventGraphicsPtr;
 
@@ -136,7 +136,7 @@ struct _virDomainEventDiskChange {
 char *newSrcPath;
 char *devAlias;
 int reason;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventDiskChange virDomainEventDiskChange;
 typedef virDomainEventDiskChange *virDomainEventDiskChangePtr;
 
@@ -145,7 +145,7 @@ struct _virDomainEventTrayChange {
 
 char *devAlias;
 int reason;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventTrayChange virDomainEventTrayChange;
 typedef virDomainEventTrayChange *virDomainEventTrayChangePtr;
 
@@ -154,7 +154,7 @@ struct _virDomainEventBalloonChange {
 
 /* In unit of 1024 bytes */
 unsigned long long actual;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventBalloonChange virDomainEventBalloonChange;
 typedef virDomainEventBalloonChange *virDomainEventBalloonChangePtr;
 
@@ -162,7 +162,7 @@ struct _virDomainEventDeviceRemoved {
 virDomainEvent parent;
 
 char *devAlias;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virDomainEventDeviceRemoved virDomainEventDeviceRemoved;
 typedef virDomainEventDeviceRemoved *virDomainEventDeviceRemovedPtr;
 
diff --git a/src/conf/network_event.c b/src/conf/network_event.c
index 4a02523..1ffcf6c 100644
--- a/src/conf/network_event.c
+++ b/src/conf/network_event.c
@@ -32,7 +32,7 @@ struct _virNetworkEventLifecycle {
 virObjectEvent parent;
 
 int type;
-};
+} ATTRIBUTE_PACKED;
 typedef struct _virNetworkEventLifecycle virNetworkEventLifecycle;
 typedef virNetworkEventLifecycle *virNetworkEventLifecyclePtr;
 
diff --git a/src/conf/object_event_private.h b/src/conf/object_event_private.h
index f41f432..34cd902 100644
--- a/src/conf/object_event_private.h
+++ b/src/conf/object_event_private.h
@@ -73,7 +73,7 @@ struct _virObjectEvent {
 virObject parent;
 int eventID;
 virObjectMeta meta;
-};
+}ATTRIBUTE_PACKED;
 
 virClassPtr
 virClassForObjectEvent(void);
-- 
1.7.9.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list