~kim0/lxc/bug-740167

« back to all changes in this revision

Viewing changes to src/lxc/confile.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter
  • Date: 2010-12-06 16:24:31 UTC
  • mfrom: (1.1.6 upstream) (3.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20101206162431-lvg92fyuiupfoqek
Tags: 0.7.3-1
* New upstream version (closes: #602631)
  - Support for specifying debian suite (closes: #600459)
  - Support for declaring a different architecture (closes: #597875)
* Fix restart init.d action sequence (closes: #597998)
* Move too-deep /usr/lib/lxc/lxc path to a proper patch
* Disable checkroot script in debian template (closes: #601001)
* Create missing tty devices under squeeze (closes: #600466)
* Restore bindmount functionality in newer kernels (closes: #604475)
* Make debian mirror configurable (closes: #601422)
* Default to cdn.debian.net as a debian mirror (closes: #600464)

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <sys/types.h>
32
32
#include <sys/param.h>
33
33
#include <sys/utsname.h>
 
34
#include <sys/personality.h>
34
35
#include <arpa/inet.h>
35
36
#include <netinet/in.h>
36
37
#include <net/if.h>
43
44
 
44
45
lxc_log_define(lxc_confile, lxc);
45
46
 
 
47
static int config_personality(const char *, char *, struct lxc_conf *);
46
48
static int config_pts(const char *, char *, struct lxc_conf *);
47
49
static int config_tty(const char *, char *, struct lxc_conf *);
48
50
static int config_cgroup(const char *, char *, struct lxc_conf *);
61
63
static int config_network_vlan_id(const char *, char *, struct lxc_conf *);
62
64
static int config_network_mtu(const char *, char *, struct lxc_conf *);
63
65
static int config_network_ipv4(const char *, char *, struct lxc_conf *);
 
66
static int config_network_script(const char *, char *, struct lxc_conf *);
64
67
static int config_network_ipv6(const char *, char *, struct lxc_conf *);
65
68
static int config_cap_drop(const char *, char *, struct lxc_conf *);
66
69
static int config_console(const char *, char *, struct lxc_conf *);
74
77
 
75
78
static struct config config[] = {
76
79
 
 
80
        { "lxc.arch",                 config_personality          },
77
81
        { "lxc.pts",                  config_pts                  },
78
82
        { "lxc.tty",                  config_tty                  },
79
83
        { "lxc.cgroup",               config_cgroup               },
88
92
        { "lxc.network.name",         config_network_name         },
89
93
        { "lxc.network.macvlan.mode", config_network_macvlan_mode },
90
94
        { "lxc.network.veth.pair",    config_network_veth_pair    },
 
95
        { "lxc.network.script.up",    config_network_script       },
91
96
        { "lxc.network.hwaddr",       config_network_hwaddr       },
92
97
        { "lxc.network.mtu",          config_network_mtu          },
93
98
        { "lxc.network.vlan.id",      config_network_vlan_id      },
475
480
        return 0;
476
481
}
477
482
 
 
483
static int config_network_script(const char *key, char *value,
 
484
                                 struct lxc_conf *lxc_conf)
 
485
{
 
486
        struct lxc_netdev *netdev;
 
487
 
 
488
        netdev = network_netdev(key, value, &lxc_conf->network);
 
489
        if (!netdev)
 
490
        return -1;
 
491
 
 
492
        char *copy = strdup(value);
 
493
        if (!copy) {
 
494
                SYSERROR("failed to dup string '%s'", value);
 
495
                return -1;
 
496
        }
 
497
        if (strcmp(key, "lxc.network.script.up") == 0) {
 
498
                netdev->upscript = copy;
 
499
                return 0;
 
500
        }
 
501
        SYSERROR("Unknown key: %s", key);
 
502
        free(copy);
 
503
        return -1;
 
504
}
 
505
 
 
506
static int config_personality(const char *key, char *value,
 
507
                              struct lxc_conf *lxc_conf)
 
508
{
 
509
        struct per_name {
 
510
                char *name;
 
511
                int per;
 
512
        } pername[4] = {
 
513
                { "x86", PER_LINUX32 },
 
514
                { "i686", PER_LINUX32 },
 
515
                { "x86_64", PER_LINUX },
 
516
                { "amd64", PER_LINUX },
 
517
        };
 
518
 
 
519
        int i;
 
520
 
 
521
        for (i = 0; i < sizeof(pername); i++) {
 
522
 
 
523
                if (strcmp(pername[i].name, value))
 
524
                    continue;
 
525
 
 
526
                lxc_conf->personality = pername[i].per;
 
527
                return 0;
 
528
        }
 
529
 
 
530
        ERROR("unsupported personality '%s'", value);
 
531
        return -1;
 
532
}
 
533
 
478
534
static int config_pts(const char *key, char *value, struct lxc_conf *lxc_conf)
479
535
{
480
536
        int maxpts = atoi(value);