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

« back to all changes in this revision

Viewing changes to src/nwfilter/nwfilter_driver.c

  • 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:
34
34
#include "memory.h"
35
35
#include "domain_conf.h"
36
36
#include "domain_nwfilter.h"
 
37
#include "nwfilter_conf.h"
37
38
#include "nwfilter_driver.h"
38
39
#include "nwfilter_gentech_driver.h"
39
40
 
42
43
 
43
44
#define VIR_FROM_THIS VIR_FROM_NWFILTER
44
45
 
45
 
#define nwfilterLog(msg...) fprintf(stderr, msg)
46
 
 
47
 
 
48
46
static virNWFilterDriverStatePtr driverState;
49
47
 
50
48
static int nwfilterDriverShutdown(void);
95
93
            goto error;
96
94
 
97
95
        if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
98
 
            nwfilterLog("out of memory in virAsprintf");
99
96
            VIR_FREE(userdir);
100
97
            goto out_of_memory;
101
98
        }
118
115
    return 0;
119
116
 
120
117
out_of_memory:
121
 
    nwfilterLog("virNWFilterStartup: out of memory");
 
118
    virReportOOMError();
122
119
 
123
120
error:
124
121
    VIR_FREE(base);
143
140
 */
144
141
static int
145
142
nwfilterDriverReload(void) {
 
143
    virConnectPtr conn;
 
144
 
146
145
    if (!driverState) {
147
146
        return -1;
148
147
    }
149
148
 
150
 
    nwfilterDriverLock(driverState);
151
 
    virNWFilterPoolLoadAllConfigs(NULL,
152
 
                                  &driverState->pools,
153
 
                                  driverState->configDir);
154
 
    nwfilterDriverUnlock(driverState);
 
149
    conn = virConnectOpen("qemu:///system");
 
150
 
 
151
    if (conn) {
 
152
        /* shut down all threads -- they will be restarted if necessary */
 
153
        virNWFilterLearnThreadsTerminate(true);
 
154
 
 
155
        nwfilterDriverLock(driverState);
 
156
        virNWFilterCallbackDriversLock();
 
157
 
 
158
        virNWFilterPoolLoadAllConfigs(conn,
 
159
                                      &driverState->pools,
 
160
                                      driverState->configDir);
 
161
 
 
162
        virNWFilterCallbackDriversUnlock();
 
163
        nwfilterDriverUnlock(driverState);
 
164
 
 
165
        virConnectClose(conn);
 
166
    }
155
167
 
156
168
    return 0;
157
169
}
321
333
    virNWFilterPtr ret = NULL;
322
334
 
323
335
    nwfilterDriverLock(driver);
 
336
    virNWFilterCallbackDriversLock();
 
337
 
324
338
    if (!(def = virNWFilterDefParseString(conn, xml)))
325
339
        goto cleanup;
326
340
 
340
354
    virNWFilterDefFree(def);
341
355
    if (pool)
342
356
        virNWFilterPoolObjUnlock(pool);
 
357
 
 
358
    virNWFilterCallbackDriversUnlock();
343
359
    nwfilterDriverUnlock(driver);
344
360
    return ret;
345
361
}
352
368
    int ret = -1;
353
369
 
354
370
    nwfilterDriverLock(driver);
 
371
    virNWFilterCallbackDriversLock();
 
372
 
355
373
    pool = virNWFilterPoolObjFindByUUID(&driver->pools, obj->uuid);
356
374
    if (!pool) {
357
375
        virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
378
396
cleanup:
379
397
    if (pool)
380
398
        virNWFilterPoolObjUnlock(pool);
 
399
 
 
400
    virNWFilterCallbackDriversUnlock();
381
401
    nwfilterDriverUnlock(driver);
382
402
    return ret;
383
403
}