]>
git.proxmox.com Git - mirror_ovs.git/blob - vswitchd/xenserver.c
1 /* Copyright (c) 2009 Nicira Networks
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #include "xenserver.h"
23 #include "dynamic-string.h"
27 #define THIS_MODULE VLM_xenserver
32 static const char filename
[] = "/etc/xensource-inventory";
36 file
= fopen(filename
, "r");
38 if (errno
== ENOENT
) {
39 VLOG_INFO("not running on a XenServer");
41 VLOG_INFO("%s: open: %s", filename
, strerror(errno
));
46 while (fgets(line
, sizeof line
, file
)) {
47 static const char leader
[] = "INSTALLATION_UUID='";
48 const int leader_len
= strlen(leader
);
49 const int uuid_len
= 36;
50 static const char trailer
[] = "'\n";
51 const int trailer_len
= strlen(trailer
);
53 if (strlen(line
) == leader_len
+ uuid_len
+ trailer_len
54 && !memcmp(line
, leader
, leader_len
)
55 && !memcmp(line
+ leader_len
+ uuid_len
, trailer
, trailer_len
)) {
56 char *host_uuid
= xmemdup0(line
+ leader_len
, uuid_len
);
57 VLOG_INFO("running on XenServer, host-uuid %s", host_uuid
);
63 VLOG_ERR("%s: INSTALLATION_UUID not found", filename
);
68 xenserver_get_host_uuid(void)
70 static char *host_uuid
;
74 host_uuid
= read_host_uuid();