提交 7e0ff3aa 编写于 作者: D Daniel Veillard

read network config in OpenVZ driver

* src/openvz_conf.c: patch from Evgeniy Sokolov to read
  network config in OpenVZ driver.
Daniel
上级 da622a20
Mon Sep 22 17:14:25 CEST 2008 Daniel Veillard <veillard@redhat.com>
* src/openvz_conf.c: patch from Evgeniy Sokolov to read
network config in OpenVZ driver.
Thu Sep 18 11:19:00 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* libvirt.spec.in: Remove commands which were deleting
......
......@@ -5,6 +5,100 @@
http://libvirt.org/news.html
0.4.5: Sep 8 2008:
- New features: NETNS support for Linux containers (Dan Smith),
unified XML domain and network parsing for all drivers (Daniel
Berrange), OpenVZ features improvements (Evgeniy Sokolov),
OpenVZ and Linux containers support now default, USB device
passthrough for QEmu/KVM (Guido Gnther), storage pool source
discovery (David Lively)
- Portability: fixes for MinGW (Atsushi SAKAI and Daniel Berrange),
detection of xen lib improvement (David Lively),
storage backend portability for SLES (David Lively),
fix make distclean and distcheck (Jim Meyering),
fix build failures on RHEL4, lot of MinGW portability fixes (Atsushi
SAKAI and Daniel Berrange), HTML generation fix, -lpthread explicit
linking when needed (Jim Meyering)
- Documentation: various typo fixes (Anton Protopopov, Toth
Istvn, Atsushi SAKAI, Nguyen Anh Quynh),
Java bindings docs, remove Xen centric
comments (Guido Gnther), various typo in comments (Chris
Lalancette), docs and API comments fixes (Charles Duffy),
how to contribute to open source link (Richard Jones),
memory unit fixups (matthew chan)
- Bug fixes: memory leaks and testing for OOM (Daniel Berrange),
do_open driver bug(Evgeniy Sokolov), don't use polkit auth when
running as non-root (Daniel Berrange), boot of CDRom devices
in QEmu/KVM (Daniel Berrange), fix OpenVZ probe function (Evgeniy
Sokolov), ID related lookup fixes in OpenVZ (Evgeniy Sokolov),
pool cration for netfs (Cole Robinson), check for migrate support
with QEmu (Guido Gnther), check against double create with QEmu
(Guido Gnther), broken open failure detection in QEmu (Guido
Gnther), UUID string conversions in QEmu (Guido Gnther),
various small cleanup and bug fixes (Daniel Berrange), ID
related fixes in the test driver (Daniel Berrange), better error
reporting on XML parsing (Daniel Berrange), empty CD-ROM source
device section (Chris Lalancette), avoid crashes for interface
without a name in QEmu (Guido Gnther), provide the real
vncport (Charles Duffy), fix forward delay (Daniel Berrange),
new VM state is initialized to be SHUTOFF (Daniel Berrange),
virsh attach-disk bug fixes (Chris Lalancette), veth clash
of device names (Dan Smith), connection lookup fixes on
storage creation (Cole Robinson), parted call fix (Cole Robinson),
use "server" option when using serial/telnet with QEmu (Mark
McLoughlin), duplicate virInitialize calls (Nguyen Anh Quynh),
many fixes to virExec and related functions (Daniel Berrange),
size of disk without partitions (Cole Robinson), creating and
cleaning up logical volumes with target path (Cole Robinson),
fix reporting of virConnectOpen problems (Daniel Berrange),
veth cleanup at shutdown (Dan Smith), lookup of Xen VMs after define
(Cole Robinson), fix emulator reported capabilities (Cole Robinson),
avoid segfault on KVM CD eject (Cole Robinson), fix disk ordering
and avoid duplicate in QEmu XML parsing (Cole Robinson), update
domain XML after device hotplug (Cole Robinson), use poweroff instead
of halt when shutting down a Xen domain (John Levon), don't dump core
of Xen domain live by default (John Levon), vgcreate command line
size bug (Jim Fehlig), signed/unsigned issue in probing file
(Cole Robinson), Fix Xen domains without PVFB console (Daniel
Berrange), OpenVZ config read bug fix (Evgeniy Sokolov).
- Improvements: improved failure diagnostic for TAP (Jim Meyering),
better exec and error diagnostic for OpenVZ commands (Evgeniy
Sokolov), OpenVZ auto start and stop of domains (Evgeniy Sokolov),
OpenVZ domain cpu time consumption (Evgeniy Sokolov), virsh
shutdown improvements and test (Jim Meyering), better report of
XML well formedness errors (Richard Jones), new XML elements
(Daniel Berrange), virsh "edit" command (Richard Jones), save
UUID of OpenVZ domains (Evgeniy Sokolov), improve xen blocks
statistics (Chris Lalancette), gnulib updates (Jim Meyering),
allow to add disk as USB devices (Guido Gnther), LXC container
process should survive libvirtd restarts (Daniel Berrange), allow
to define static host domain configs, number of CPU used by
OpenVZ domains (Evgeniy Sokolov), private root fs for LXC (Daniel
Berrange), storage source information in storage pools (David Lively),
virsh reports attach and detach success (Cole Robinson), detect
failure in QEmu eject command (Cole Robinson), add support for
eect on floppy and SCSI cdroms for QEmu (Cole Robinson), LXC
hypervisor version extraction (Dan Smith), Augeas config file support
(Daniel Berrange), support for a domain name in network
config (JJ Reynolds).
- Cleanups: Python verbosity cleanup (Ryan Scott),
space and tabs cleanups (Atsushi SAKAI), OpenVZ and LXC drivers
cleanup and unification of XML handling (Daniel Berrange), updates
to Relax-NG XML schemas (John Levon and Daniel Berrange), more
printf format checkings (Jim Meyering), VIR_FREE related cleanups
(Jim Meyering), integer string parsing cleanup (Evgeniy Sokolov),
initial OpenVZ xml refactoring (Evgeniy Sokolov), better error
message on domain redefine (Charles Duffy), check XML files against
the RNG Schemas (Daniel Berrange), const-correctness in virsh
(Richard Jones and Jim Meyering), const-correctness and cleanups
in LXC and OpenVZ drivers (Daniel Berrange), virFileLinkPointsTo
rewrite (Jim Meyering), cleanup of the conditional compilation
of C files (Daniel Berrange), shell quoting fixes (Jim Meyering),
parallel build support (James Morris and Jim Meyering), new
convenenience virFileReadLimFD function (Jim Meyering).
0.4.4: Jun 25 2008:
- Bug fixes: QEmu network serialization (Kaitlin Rupert), internal
memory allocation fixes (Chris Lalancette Jim Meyering), virsh
......
......@@ -151,6 +151,146 @@ char *openvzMacToString(const unsigned char *mac)
return strdup(str);
}
/*parse MAC from view: 00:18:51:8F:D9:F3
return -1 - error
0 - OK
*/
static int openvzParseMac(const char *macaddr, unsigned char *mac)
{
int ret;
ret = sscanf((const char *)macaddr, "%02X:%02X:%02X:%02X:%02X:%02X",
(unsigned int*)&mac[0],
(unsigned int*)&mac[1],
(unsigned int*)&mac[2],
(unsigned int*)&mac[3],
(unsigned int*)&mac[4],
(unsigned int*)&mac[5]) ;
if (ret == 6)
return 0;
return -1;
}
static virDomainNetDefPtr
openvzReadNetworkConf(virConnectPtr conn, int veid) {
int ret;
virDomainNetDefPtr net = NULL;
virDomainNetDefPtr new_net;
char temp[4096];
char *token, *saveptr = NULL;
/*parse routing network configuration*
* Sample from config:
* IP_ADDRESS="1.1.1.1 1.1.1.2"
* splited IPs by space
*/
ret = openvzReadConfigParam(veid, "IP_ADDRESS", temp, sizeof(temp));
if (ret < 0) {
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
_("Cound not read 'IP_ADDRESS' from config for container %d"),
veid);
goto error;
} else if (ret > 0) {
token = strtok_r(temp, " ", &saveptr);
while (token != NULL) {
new_net = NULL;
if (VIR_ALLOC(new_net) < 0)
goto no_memory;
new_net->next = net;
net = new_net;
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
net->data.ethernet.ipaddr = strdup(token);
if (net->data.ethernet.ipaddr == NULL)
goto no_memory;
token = strtok_r(NULL, " ", &saveptr);
}
}
/*parse bridge devices*/
/*Sample from config:
*NETIF="ifname=eth10,mac=00:18:51:C1:05:EE,host_ifname=veth105.10,host_mac=00:18:51:8F:D9:F3"
*devices splited by ';'
*/
ret = openvzReadConfigParam(veid, "NETIF", temp, sizeof(temp));
if (ret < 0) {
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
_("Cound not read 'NETIF' from config for container %d"),
veid);
goto error;
} else if (ret > 0) {
token = strtok_r(temp, ";", &saveptr);
while (token != NULL) {
/*add new device to list*/
new_net = NULL;
if (VIR_ALLOC(new_net) < 0)
goto no_memory;
new_net->next = net;
net = new_net;
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
char *p = token, *next = token;
char cpy_temp[32];
int len;
/*parse string*/
do {
while (*next != '\0' && *next != ',') next++;
if (STRPREFIX(p, "ifname=")) {
p += 7;
len = next - p;
if (len > 16) {
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
_("Too long network device name"));
goto error;
}
if (VIR_ALLOC_N(net->data.bridge.brname, len+1) < 0)
goto no_memory;
strncpy(net->data.bridge.brname, p, len);
net->data.bridge.brname[len] = '\0';
} else if (STRPREFIX(p, "host_ifname=")) {
p += 12;
//skip in libvirt
} else if (STRPREFIX(p, "mac=")) {
p += 4;
len = next - p;
if (len != 17) { //should be 17
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
_("Wrong length MAC address"));
goto error;
}
strncpy(cpy_temp, p, len);
cpy_temp[len] = '\0';
if (openvzParseMac(cpy_temp, net->mac)<0) {
openvzError(conn, VIR_ERR_INTERNAL_ERROR,
_("Wrong MAC address"));
goto error;
}
} else if (STRPREFIX(p, "host_mac=")) {
p += 9;
//skip in libvirt
}
p = ++next;
} while (p < token + strlen(token));
token = strtok_r(NULL, ";", &saveptr);
}
}
return net;
no_memory:
openvzError(conn, VIR_ERR_NO_MEMORY, NULL);
error:
virDomainNetDefFree(net);
return NULL;
}
/* Free all memory associated with a openvz_driver structure */
void
openvzFreeDriver(struct openvz_driver *driver)
......@@ -243,6 +383,8 @@ int openvzLoadDomains(struct openvz_driver *driver) {
/* XXX load rest of VM config data .... */
dom->def->nets = openvzReadNetworkConf(NULL, veid);
if (prev) {
prev->next = dom;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册