~serge-hallyn/ubuntu/oneiric/libvirt/fix-shutdown

« back to all changes in this revision

Viewing changes to debian/patches/9027-Make-newfilter-xml-transformations-endian-safe.patch

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2010-11-02 16:26:51 UTC
  • mfrom: (1.2.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20101102162651-aq8tnbz58mdf01bf
Tags: 0.8.5-0ubuntu1
* New upstream release.
* Removed a slew of patches which have been
  applied upstream since 0.8.3.
  - 9012-apparmor-extra-tests.patch
  - 9013-apparmor-chardev.patch
  - 9015-Add-ubd-to-the-list-of-disk-prefixes.patch
  - 9016-Close-fd-s-of-persistent-tap-devices.patch
  - 9017-Make-sure-all-command-line-arguments-get-passed-to-U.patch
  - 9018-Make-umlConnectTapDevice-ask-brAddTap-for-a-persiste.patch
  - 9019-uml-fix-logic-bug-in-checking-reply-length.patch
  - 9021-Allow-chardev-of-type-file-for-UML-domains.patch
  - 9022-Rename-qemudShrinkDisks-to-virDomainDiskRemove-and-m.patch
  - 9023-Support-virDomainAttachDevice-and-virDomainDetachDev.patch
  - 9024-Explicitly-pass-uml_dir-argument-to-user-mode-linux.patch
  - 9025-Add-nwfilter-support-to-UML-driver.patch
  - 9026-Rebuild-network-filter-for-UML-guests-on-updates.patch
  - 9027-Make-newfilter-xml-transformations-endian-safe.patch
  - 9028-lp628055.patch
* Updated 9002-better_default_uri_virsh.patch to use vshStrdup,
  as now required in that file.  (use of strdup now causes compilation
  to fail)
* Removed 9008-run-as-root-by-default.patch, which has not been
  applied for awhile now, with no ill effects.
* Simple refresh of:
  - 0001-remove-RHism.diff.patch
  - 0003-allow-libvirt-group-to-access-the-socket.patch
  - 0004-fix-Debian-specific-path-to-hvm-loader.patch
  - 0006-patch-qemuMonitorTextGetMigrationStatus-to-intercept.patch
  - 9000-delayed_iff_up_bridge.patch
  - 9001-dont_clobber_existing_bridges.patch
  - 9003-better-default-arch.patch
  - 9004-libvirtd-group-name.patch
  - 9005-increase-unix-socket-timeout.patch
  - 9006-default-config-test-case.patch
  - 9009-autodetect-nc-params.patch
  - 9010-dont-disable-ipv6.patch
  - 9011-move-ebtables-script.patch
  - 9014-skip-nodeinfotest.patch
  - 9020-lp545795.patch
* Create a patch to include stdint.h so lxc_container.h, which
  #includes linux/fs.h, doesn't trip up on undefined uint64_t.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Subject: nwfilter: fix an bug appearing on big endian machines
2
 
Origin: https://www.redhat.com/archives/libvir-list/2010-September/msg00297.html
3
 
Author: Stefan Berger <stefanb@linux.vnet.ibm.com>
4
 
Forwarded: not-needed
5
 
Applied-Upstream: No
6
 
 
7
 
Index: libvirt-0.8.3/src/conf/nwfilter_conf.c
8
 
===================================================================
9
 
--- libvirt-0.8.3.orig/src/conf/nwfilter_conf.c 2010-09-20 19:13:41.055669000 +0900
10
 
+++ libvirt-0.8.3/src/conf/nwfilter_conf.c      2010-09-20 19:13:43.695669002 +0900
11
 
@@ -379,9 +379,14 @@
12
 
     }
13
 
 }
14
 
 
15
 
+union data {
16
 
+    void *v;
17
 
+    char *c;
18
 
+    unsigned char *uc;
19
 
+    unsigned int ui;
20
 
+};
21
 
 
22
 
-
23
 
-typedef bool (*valueValidator)(enum attrDatatype datatype, void *valptr,
24
 
+typedef bool (*valueValidator)(enum attrDatatype datatype, union data *valptr,
25
 
                                virNWFilterRuleDefPtr nwf);
26
 
 typedef bool (*valueFormatter)(virBufferPtr buf,
27
 
                                virNWFilterRuleDefPtr nwf);
28
 
@@ -407,18 +412,18 @@
29
 
 
30
 
 
31
 
 static bool
32
 
-checkMacProtocolID(enum attrDatatype datatype, void *value,
33
 
+checkMacProtocolID(enum attrDatatype datatype, union data *value,
34
 
                    virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
35
 
 {
36
 
     int32_t res = -1;
37
 
 
38
 
     if (datatype == DATATYPE_STRING) {
39
 
-        if (intMapGetByString(macProtoMap, (char *)value, 1, &res) == 0)
40
 
+        if (intMapGetByString(macProtoMap, value->c, 1, &res) == 0)
41
 
             res = -1;
42
 
         datatype = DATATYPE_UINT16;
43
 
     } else if (datatype == DATATYPE_UINT16 ||
44
 
                datatype == DATATYPE_UINT16_HEX) {
45
 
-        res = (uint32_t)*(uint16_t *)value;
46
 
+        res = value->ui;
47
 
         if (res < 0x600)
48
 
             res = -1;
49
 
     }
50
 
@@ -485,10 +490,10 @@
51
 
 
52
 
 static bool
53
 
 checkMACMask(enum attrDatatype datatype ATTRIBUTE_UNUSED,
54
 
-             void *macMask,
55
 
+             union data *macMask,
56
 
              virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
57
 
 {
58
 
-    return checkValidMask((unsigned char *)macMask, 6);
59
 
+    return checkValidMask(macMask->uc, 6);
60
 
 }
61
 
 
62
 
 
63
 
@@ -511,18 +516,18 @@
64
 
 
65
 
 static bool
66
 
 arpOpcodeValidator(enum attrDatatype datatype,
67
 
-                   void *value,
68
 
+                   union data *value,
69
 
                    virNWFilterRuleDefPtr nwf)
70
 
 {
71
 
     int32_t res = -1;
72
 
 
73
 
     if (datatype == DATATYPE_STRING) {
74
 
-        if (intMapGetByString(arpOpcodeMap, (char *)value, 1, &res) == 0)
75
 
+        if (intMapGetByString(arpOpcodeMap, value->c, 1, &res) == 0)
76
 
             res = -1;
77
 
         datatype = DATATYPE_UINT16;
78
 
     } else if (datatype == DATATYPE_UINT16 ||
79
 
                datatype == DATATYPE_UINT16_HEX) {
80
 
-        res = (uint32_t)*(uint16_t *)value;
81
 
+        res = (uint32_t)value->ui;
82
 
     }
83
 
 
84
 
     if (res != -1) {
85
 
@@ -570,18 +575,18 @@
86
 
 
87
 
 
88
 
 static bool checkIPProtocolID(enum attrDatatype datatype,
89
 
-                              void *value,
90
 
+                              union data *value,
91
 
                               virNWFilterRuleDefPtr nwf)
92
 
 {
93
 
     int32_t res = -1;
94
 
 
95
 
     if (datatype == DATATYPE_STRING) {
96
 
-        if (intMapGetByString(ipProtoMap, (char *)value, 1, &res) == 0)
97
 
+        if (intMapGetByString(ipProtoMap, value->c, 1, &res) == 0)
98
 
             res = -1;
99
 
         datatype = DATATYPE_UINT8_HEX;
100
 
     } else if (datatype == DATATYPE_UINT8 ||
101
 
                datatype == DATATYPE_UINT8_HEX) {
102
 
-        res = (uint32_t)*(uint16_t *)value;
103
 
+        res = (uint32_t)value->ui;
104
 
     }
105
 
 
106
 
     if (res != -1) {
107
 
@@ -615,10 +620,10 @@
108
 
 
109
 
 
110
 
 static bool
111
 
-dscpValidator(enum attrDatatype datatype, void *val,
112
 
+dscpValidator(enum attrDatatype datatype, union data *val,
113
 
               virNWFilterRuleDefPtr nwf)
114
 
 {
115
 
-    uint8_t dscp = *(uint16_t *)val;
116
 
+    uint8_t dscp = val->ui;
117
 
     if (dscp > 63)
118
 
         return 0;
119
 
 
120
 
@@ -1150,7 +1155,8 @@
121
 
     nwItemDesc *item;
122
 
     int int_val;
123
 
     unsigned int uint_val;
124
 
-    void *data_ptr = NULL, *storage_ptr;
125
 
+    void *storage_ptr;
126
 
+    union data data;
127
 
     valueValidator validator;
128
 
     char *match = virXMLPropString(node, "match");
129
 
     nwIPAddress ipaddr;
130
 
@@ -1206,7 +1212,7 @@
131
 
                                 if (uint_val <= 0xff) {
132
 
                                     *(uint8_t *)storage_ptr = uint_val;
133
 
                                     found = 1;
134
 
-                                    data_ptr = &uint_val;
135
 
+                                    data.ui = uint_val;
136
 
                                 } else
137
 
                                     rc = -1;
138
 
                             } else
139
 
@@ -1221,7 +1227,7 @@
140
 
                                 if (uint_val <= 0xffff) {
141
 
                                     *(uint16_t *)storage_ptr = uint_val;
142
 
                                     found = 1;
143
 
-                                    data_ptr = &uint_val;
144
 
+                                    data.ui = uint_val;
145
 
                                 } else
146
 
                                     rc = -1;
147
 
                             } else
148
 
@@ -1245,7 +1251,7 @@
149
 
                                         *(uint8_t *)storage_ptr =
150
 
                                                (uint8_t)uint_val;
151
 
                                     found = 1;
152
 
-                                    data_ptr = &uint_val;
153
 
+                                    data.ui = uint_val;
154
 
                                 } else
155
 
                                     rc = -1;
156
 
                             } else {
157
 
@@ -1278,7 +1284,7 @@
158
 
                                         (nwMACAddressPtr)storage_ptr)) {
159
 
                                 rc = -1;
160
 
                             }
161
 
-                            data_ptr = storage_ptr;
162
 
+                            data.v = storage_ptr;
163
 
                             found = 1;
164
 
                         break;
165
 
 
166
 
@@ -1299,7 +1305,7 @@
167
 
                                         *(uint8_t *)storage_ptr =
168
 
                                                (uint8_t)uint_val;
169
 
                                     found = 1;
170
 
-                                    data_ptr = &uint_val;
171
 
+                                    data.ui = uint_val;
172
 
                                 } else
173
 
                                     rc = -1;
174
 
                             } else {
175
 
@@ -1322,7 +1328,7 @@
176
 
                                 rc = -1;
177
 
                                 break;
178
 
                             }
179
 
-                            data_ptr = prop;
180
 
+                            data.c = prop;
181
 
                             found = 1;
182
 
                         break;
183
 
 
184
 
@@ -1344,7 +1350,7 @@
185
 
                 *flags = NWFILTER_ENTRY_ITEM_FLAG_EXISTS | flags_set;
186
 
                 item->datatype = datatype >> 1;
187
 
                 if (validator) {
188
 
-                    if (!validator(datatype >> 1, data_ptr, nwf)) {
189
 
+                    if (!validator(datatype >> 1, &data, nwf)) {
190
 
                         rc = -1;
191
 
                         *flags = 0;
192
 
                     }