6524928 domU console shouldn't drop when the domain reboots 6664507 virsh console command on Xen DomU system does not enforce console write exclusivity 6718462 need HVM serial support in virt-install 6718906 xVM console should be more verbose
1 Solaris dom0 support 2 3 diff --git a/src/console.c b/src/console.c 4 --- a/src/console.c 5 +++ b/src/console.c 6 @@ -56,6 +56,11 @@ cfmakeraw (struct termios *attr) 7 attr->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); 8 attr->c_cflag &= ~(CSIZE | PARENB); 9 attr->c_cflag |= CS8; 10 + 11 +#ifdef __sun 12 + attr->c_cc[VMIN] = 0; 13 + attr->c_cc[VTIME] = 0; 14 +#endif 15 } 16 #endif /* !HAVE_CFMAKERAW */ 17 18 diff --git a/src/xen_internal.c b/src/xen_internal.c 19 --- a/src/xen_internal.c 20 +++ b/src/xen_internal.c 21 @@ -70,7 +70,7 @@ typedef struct v1_hypercall_struct 22 #define XEN_V1_IOCTL_HYPERCALL_CMD \ 23 _IOC(_IOC_NONE, 'P', 0, sizeof(v1_hypercall_t)) 24 typedef v1_hypercall_t hypercall_t; 25 -#elif define(__sun__) 26 +#elif defined(__sun) 27 typedef privcmd_hypercall_t hypercall_t; 28 #else 29 #error "unsupported platform" 30 @@ -335,8 +335,10 @@ lock_pages(void *addr, size_t len) 31 { 32 #ifdef __linux__ 33 return (mlock(addr, len)); 34 -#elif define(__sun) 35 +#elif defined(__sun) 36 return (0); 37 +#else 38 +#error "unsupported platform" 39 #endif 40 } 41 42 @@ -345,8 +347,10 @@ unlock_pages(void *addr, size_t len) 43 { 44 #ifdef __linux__ 45 return (munlock(addr, len)); 46 -#elif define(__sun) 47 +#elif defined(__sun) 48 return (0); 49 +#else 50 +#error "unsupported platform" 51 #endif 52 } 53 54 @@ -661,7 +665,7 @@ typedef struct xen_op_v2_dom xen_op_v2_d 55 #define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd" 56 #define HYPERVISOR_CAPABILITIES "/sys/hypervisor/properties/capabilities" 57 #define CPUINFO "/proc/cpuinfo" 58 -#elif define(__sun__) 59 +#elif defined(__sun) 60 #define XEN_HYPERVISOR_SOCKET "/dev/xen/privcmd" 61 #define HYPERVISOR_CAPABILITIES "" 62 #define CPUINFO "/dev/cpu/self/cpuid" 63 @@ -2020,7 +2024,7 @@ xenHypervisorInit(void) 64 goto detect_v2; 65 } 66 67 -#ifndef __sun__ 68 +#ifndef __sun 69 /* 70 * check if the old hypercall are actually working 71 */ 72 @@ -2249,6 +2253,92 @@ xenHypervisorGetVersion(virConnectPtr co 73 return(0); 74 } 75 76 +#ifdef __linux__ 77 +void 78 +loadCapabilities(FILE *cpuinfo, FILE *capabilities, char *hvm_type, 79 + int *host_pae, char *line, int LINE_SIZE) 80 +{ 81 + regmatch_t subs[4]; 82 + 83 + /* /proc/cpuinfo: flags: Intel calls HVM "vmx", AMD calls it "svm". 84 + * It's not clear if this will work on IA64, let alone other 85 + * architectures and non-Linux. (XXX) 86 + */ 87 + if (cpuinfo) { 88 + while (fgets (line, LINE_SIZE, cpuinfo)) { 89 + if (regexec (&flags_hvm_rec, line, 90 + sizeof(subs)/sizeof(regmatch_t), subs, 0) == 0 91 + && subs[0].rm_so != -1) { 92 + strncpy (hvm_type, 93 + &line[subs[1].rm_so], subs[1].rm_eo-subs[1].rm_so+1); 94 + hvm_type[subs[1].rm_eo-subs[1].rm_so] = '\0'; 95 + } else if (regexec (&flags_pae_rec, line, 0, NULL, 0) == 0) 96 + *host_pae = 1; 97 + } 98 + } 99 + 100 + /* Expecting one line in this file - ignore any more. */ 101 + (void) fgets(line, LINE_SIZE, capabilities); 102 +} 103 + 104 +#else 105 +void 106 +loadCapabilities(FILE *cpuinfo, FILE *capabilities, char *hvm_type, 107 + int *host_pae, char *line, int LINE_SIZE) 108 +{ 109 + struct { 110 + uint32_t r_eax, r_ebx, r_ecx, r_edx; 111 + } _r, *rp = &_r; 112 + int d, cmd; 113 + char *s; 114 + hypercall_t hc; 115 + 116 + 117 + if ((d = open(CPUINFO, O_RDONLY)) == -1) { 118 + goto cpuinfo_open_fail; 119 + } 120 + 121 + if (pread(d, rp, sizeof (*rp), 0) != sizeof (*rp)) { 122 + goto cpuinfo_pread_fail; 123 + } 124 + 125 + s = (char *)&rp->r_ebx; 126 + if (strncmp(s, "Auth" "cAMD" "enti", 12) == 0) { 127 + if (pread(d, rp, sizeof (*rp), 0x80000001) == sizeof (*rp)) { 128 + /* Read secure virtual machine bit (bit 2 of ECX feature ID) */ 129 + if ((rp->r_ecx >> 2) & 1) { 130 + strcpy(hvm_type, "svm"); 131 + } 132 + if ((rp->r_edx >> 6) & 1) { 133 + *host_pae = 1; 134 + } 135 + } 136 + } else if (strncmp(s, "Genu" "ntel" "ineI", 12) == 0) { 137 + if (pread(d, rp, sizeof (*rp), 0x00000001) == sizeof (*rp)) { 138 + /* Read VMXE feature bit (bit 5 of ECX feature ID) */ 139 + if ((rp->r_ecx >> 5) & 1) { 140 + strcpy(hvm_type, "vmx"); 141 + } 142 + if ((rp->r_edx >> 6) & 1) { 143 + *host_pae = 1; 144 + } 145 + } 146 + } 147 +cpuinfo_pread_fail: 148 + (void) close(d); 149 +cpuinfo_open_fail: 150 + 151 + d = open(XEN_HYPERVISOR_SOCKET, O_RDWR); 152 + hc.op = __HYPERVISOR_xen_version; 153 + hc.arg[0] = (unsigned long) XENVER_capabilities; 154 + hc.arg[1] = (unsigned long) line; 155 + cmd = IOCTL_PRIVCMD_HYPERCALL; 156 + (void) ioctl(d, cmd, (unsigned long) &hc); 157 + close(d); 158 +} 159 + 160 +#endif 161 + 162 /** 163 * xenHypervisorGetCapabilities: 164 * @conn: pointer to the connection block 165 @@ -2262,7 +2352,8 @@ xenHypervisorMakeCapabilitiesXML(virConn 166 const char *hostmachine, 167 FILE *cpuinfo, FILE *capabilities) 168 { 169 - char line[1024], *str, *token; 170 + const int LINE_SIZE = 1024; 171 + char line[LINE_SIZE], *str, *token; 172 regmatch_t subs[4]; 173 char *saveptr = NULL; 174 int i, r, topology; 175 @@ -2287,24 +2378,12 @@ xenHypervisorMakeCapabilitiesXML(virConn 176 177 memset(guest_archs, 0, sizeof(guest_archs)); 178 179 - /* /proc/cpuinfo: flags: Intel calls HVM "vmx", AMD calls it "svm". 180 - * It's not clear if this will work on IA64, let alone other 181 - * architectures and non-Linux. (XXX) 182 - */ 183 - if (cpuinfo) { 184 - while (fgets (line, sizeof line, cpuinfo)) { 185 - if (regexec (&flags_hvm_rec, line, sizeof(subs)/sizeof(regmatch_t), subs, 0) == 0 186 - && subs[0].rm_so != -1) { 187 - strncpy (hvm_type, 188 - &line[subs[1].rm_so], subs[1].rm_eo-subs[1].rm_so+1); 189 - hvm_type[subs[1].rm_eo-subs[1].rm_so] = '\0'; 190 - } else if (regexec (&flags_pae_rec, line, 0, NULL, 0) == 0) 191 - host_pae = 1; 192 - } 193 - } 194 - 195 - /* Most of the useful info is in /sys/hypervisor/properties/capabilities 196 - * which is documented in the code in xen-unstable.hg/xen/arch/.../setup.c. 197 + memset(line, 0, sizeof(line)); 198 + loadCapabilities(cpuinfo, capabilities, hvm_type, &host_pae, line, 199 + LINE_SIZE); 200 + 201 + /* The capabilities line is documented in the code in 202 + * xen-unstable.hg/xen/arch/.../setup.c. 203 * 204 * It is a space-separated list of supported guest architectures. 205 * 206 @@ -2327,77 +2406,74 @@ xenHypervisorMakeCapabilitiesXML(virConn 207 * +--------------- "xen" or "hvm" for para or full virt respectively 208 */ 209 210 - /* Expecting one line in this file - ignore any more. */ 211 - if (fgets (line, sizeof line, capabilities)) { 212 - /* Split the line into tokens. strtok_r is OK here because we "own" 213 - * this buffer. Parse out the features from each token. 214 - */ 215 - for (str = line, nr_guest_archs = 0; 216 - nr_guest_archs < sizeof guest_archs / sizeof guest_archs[0] 217 - && (token = strtok_r (str, " ", &saveptr)) != NULL; 218 - str = NULL) { 219 - 220 - if (regexec (&xen_cap_rec, token, sizeof subs / sizeof subs[0], 221 - subs, 0) == 0) { 222 - int hvm = strncmp (&token[subs[1].rm_so], "hvm", 3) == 0; 223 - const char *model; 224 - int bits, pae = 0, nonpae = 0, ia64_be = 0; 225 - if (strncmp (&token[subs[2].rm_so], "x86_32", 6) == 0) { 226 - model = "i686"; 227 - bits = 32; 228 - if (strncmp (&token[subs[3].rm_so], "p", 1) == 0) 229 - pae = 1; 230 - else 231 - nonpae = 1; 232 + /* Split the line into tokens. strtok_r is OK here because we "own" 233 + * this buffer. Parse out the features from each token. 234 + */ 235 + for (str = line, nr_guest_archs = 0; 236 + nr_guest_archs < sizeof guest_archs / sizeof guest_archs[0] 237 + && (token = strtok_r (str, " ", &saveptr)) != NULL; 238 + str = NULL) { 239 + 240 + if (regexec (&xen_cap_rec, token, sizeof subs / sizeof subs[0], 241 + subs, 0) == 0) { 242 + int hvm = strncmp (&token[subs[1].rm_so], "hvm", 3) == 0; 243 + const char *model; 244 + int bits, pae = 0, nonpae = 0, ia64_be = 0; 245 + if (strncmp (&token[subs[2].rm_so], "x86_32", 6) == 0) { 246 + model = "i686"; 247 + bits = 32; 248 + if (strncmp (&token[subs[3].rm_so], "p", 1) == 0) 249 + pae = 1; 250 + else 251 + nonpae = 1; 252 + } 253 + else if (strncmp (&token[subs[2].rm_so], "x86_64", 6) == 0) { 254 + model = "x86_64"; 255 + bits = 64; 256 + } 257 + else if (strncmp (&token[subs[2].rm_so], "ia64", 4) == 0) { 258 + model = "ia64"; 259 + bits = 64; 260 + if (strncmp (&token[subs[3].rm_so], "be", 2) == 0) 261 + ia64_be = 1; 262 + } 263 + else if (strncmp (&token[subs[2].rm_so], "powerpc64", 4) == 0) { 264 + model = "ppc64"; 265 + bits = 64; 266 + } else { 267 + /* XXX surely no other Xen archs exist */ 268 + continue; 269 + } 270 + 271 + /* Search for existing matching (model,hvm) tuple */ 272 + for (i = 0 ; i < nr_guest_archs ; i++) { 273 + if (!strcmp(guest_archs[i].model, model) && 274 + guest_archs[i].hvm == hvm) { 275 + break; 276 } 277 - else if (strncmp (&token[subs[2].rm_so], "x86_64", 6) == 0) { 278 - model = "x86_64"; 279 - bits = 64; 280 - } 281 - else if (strncmp (&token[subs[2].rm_so], "ia64", 4) == 0) { 282 - model = "ia64"; 283 - bits = 64; 284 - if (strncmp (&token[subs[3].rm_so], "be", 2) == 0) 285 - ia64_be = 1; 286 - } 287 - else if (strncmp (&token[subs[2].rm_so], "powerpc64", 4) == 0) { 288 - model = "ppc64"; 289 - bits = 64; 290 - } else { 291 - /* XXX surely no other Xen archs exist */ 292 - continue; 293 - } 294 - 295 - /* Search for existing matching (model,hvm) tuple */ 296 - for (i = 0 ; i < nr_guest_archs ; i++) { 297 - if (!strcmp(guest_archs[i].model, model) && 298 - guest_archs[i].hvm == hvm) { 299 - break; 300 - } 301 - } 302 - 303 - /* Too many arch flavours - highly unlikely ! */ 304 - if (i >= sizeof(guest_archs)/sizeof(guest_archs[0])) 305 - continue; 306 - /* Didn't find a match, so create a new one */ 307 - if (i == nr_guest_archs) 308 - nr_guest_archs++; 309 - 310 - guest_archs[i].model = model; 311 - guest_archs[i].bits = bits; 312 - guest_archs[i].hvm = hvm; 313 - 314 - /* Careful not to overwrite a previous positive 315 - setting with a negative one here - some archs 316 - can do both pae & non-pae, but Xen reports 317 - separately capabilities so we're merging archs */ 318 - if (pae) 319 - guest_archs[i].pae = pae; 320 - if (nonpae) 321 - guest_archs[i].nonpae = nonpae; 322 - if (ia64_be) 323 - guest_archs[i].ia64_be = ia64_be; 324 } 325 + 326 + /* Too many arch flavours - highly unlikely ! */ 327 + if (i >= sizeof(guest_archs)/sizeof(guest_archs[0])) 328 + continue; 329 + /* Didn't find a match, so create a new one */ 330 + if (i == nr_guest_archs) 331 + nr_guest_archs++; 332 + 333 + guest_archs[i].model = model; 334 + guest_archs[i].bits = bits; 335 + guest_archs[i].hvm = hvm; 336 + 337 + /* Careful not to overwrite a previous positive 338 + setting with a negative one here - some archs 339 + can do both pae & non-pae, but Xen reports 340 + separately capabilities so we're merging archs */ 341 + if (pae) 342 + guest_archs[i].pae = pae; 343 + if (nonpae) 344 + guest_archs[i].nonpae = nonpae; 345 + if (ia64_be) 346 + guest_archs[i].ia64_be = ia64_be; 347 } 348 } 349 350 @@ -2543,29 +2619,33 @@ xenHypervisorGetCapabilities (virConnect 351 /* Really, this never fails - look at the man-page. */ 352 uname (&utsname); 353 354 - cpuinfo = fopen ("/proc/cpuinfo", "r"); 355 +#ifdef __linux__ 356 + cpuinfo = fopen (CPUINFO, "r"); 357 if (cpuinfo == NULL) { 358 if (errno != ENOENT) { 359 - virXenPerror (conn, "/proc/cpuinfo"); 360 + virXenPerror (conn, CPUINFO); 361 return NULL; 362 } 363 } 364 365 - capabilities = fopen ("/sys/hypervisor/properties/capabilities", "r"); 366 + capabilities = fopen (HYPERVISOR_CAPABILITIES, "r"); 367 if (capabilities == NULL) { 368 if (errno != ENOENT) { 369 fclose(cpuinfo); 370 - virXenPerror (conn, "/sys/hypervisor/properties/capabilities"); 371 + virXenPerror (conn, HYPERVISOR_CAPABILITIES); 372 return NULL; 373 } 374 } 375 +#endif 376 377 xml = xenHypervisorMakeCapabilitiesXML(conn, utsname.machine, cpuinfo, capabilities); 378 379 +#ifdef __linux__ 380 if (cpuinfo) 381 fclose(cpuinfo); 382 if (capabilities) 383 fclose(capabilities); 384 +#endif 385 386 return xml; 387 } 388 diff --git a/src/xs_internal.c b/src/xs_internal.c 389 --- a/src/xs_internal.c 390 +++ b/src/xs_internal.c 391 @@ -33,7 +33,7 @@ 392 393 #ifdef __linux__ 394 #define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd" 395 -#elif define(__sun__) 396 +#elif defined(__sun) 397 #define XEN_HYPERVISOR_SOCKET "/dev/xen/privcmd" 398 #else 399 #error "unsupported platform" --- EOF ---