~ubuntu-branches/ubuntu/natty/libvirt/natty-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * domain_nwfilter.c:
 *
 * Copyright (C) 2010 IBM Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * Author: Stefan Berger <stefanb@us.ibm.com>
 */

#include <config.h>

#include "internal.h"

#include "datatypes.h"
#include "domain_conf.h"
#include "domain_nwfilter.h"

static virDomainConfNWFilterDriverPtr nwfilterDriver;

void
virDomainConfNWFilterRegister(virDomainConfNWFilterDriverPtr driver) {
    nwfilterDriver = driver;
}

int
virDomainConfNWFilterInstantiate(virConnectPtr conn,
                                 virDomainNetDefPtr net) {
    if (nwfilterDriver != NULL)
        return nwfilterDriver->instantiateFilter(conn, net);
    /* driver module not available -- don't indicate failure */
    return 0;
}

void
virDomainConfNWFilterTeardown(virDomainNetDefPtr net) {
    if (nwfilterDriver != NULL)
        nwfilterDriver->teardownFilter(net);
}

void
virDomainConfVMNWFilterTeardown(virDomainObjPtr vm) {
    int i;

    if (nwfilterDriver != NULL) {
        for (i = 0; i < vm->def->nnets; i++)
            virDomainConfNWFilterTeardown(vm->def->nets[i]);
    }
}