The Book of Xen

Chris Takemura - Luke S. Crawford

Part 20

Report Chapter
webnovel
webnovel

[86] Once upon a time you had to download a patch and rebuild. Thankfully, this is no longer the case. Once upon a time you had to download a patch and rebuild. Thankfully, this is no longer the case.

Python Path Issues The Python path itself can be the subject of some irritation. Just as you've got your sh.e.l.l executable path, manpath, library path, and so forth, Python has its own internal search path that it examines for modules. If the path doesn't include the Xen modules, you can wind up with errors like the following: #xmcreate-csebastian.cfg Usingconfigfile"/etc/xen/sebastian.cfg".

Traceback(mostrecentcalllast): File"/usr/bin/pygrub",line26,in?

importgrub.fsys ImportError:Nomodulenamedfsys Unfortunately, the mechanisms for adjusting the search path aren't exactly intuitive. In most cases, we just fall back to either creating some symlinks or moving the Xen files into some directory that's already in Python's path.

The correct solution is to add a .pth .pth file to a directory that's already in Python's path. This file to a directory that's already in Python's path. This .pth .pth file should contain the path of a directory with Python modules. For example: file should contain the path of a directory with Python modules. For example: #echo"/usr/local/lib/python2.5/site-packages">> /usr/lib/python2.5/local.pth Confirm that the path updated correctly by starting Python: #python

>>>>importsys >>>>printsys.path ['','/usr/lib/python25.zip','usr/lib/python2.5'(etc) '/usr/local/lib/python2.5/site-packages']

Mysterious Lockups Mysterious lockups are among the most frustrating aspects of dealing with computers; sometimes they just don't work.

If Xen (or the dom0) hangs mysteriously, chances are you have a kernel panic in the dom0. In this case, you have two problems: first, the crash; second, your console logging isn't adequate to its task.

A serial console improves your life immensely. If you're using serial, you should see an informative panic message on the serial console. If you don't see that, you may want to try typing CTRL-A three times on the console to switch the input to the Xen hypervisor. This will at least confirm that Xen and the hardware are still up.

If you don't have a serial console, try to keep your VGA console on tty1 because often the panic message won't go anywhere else. Sometimes a digital camera is handy for saving the output of a kernel panic.

If the box reboots before you can see the panic message on your console, and serial isn't an option, you can try adding panic=0 panic=0 to the to the module module line that specifies your Linux kernel in the domU line that specifies your Linux kernel in the domU menu.lst menu.lst file. This has the obvious disadvantage of hanging your computer rather than rebooting, but it's good for test setups because it'll at least let you see the computer's final messages. file. This has the obvious disadvantage of hanging your computer rather than rebooting, but it's good for test setups because it'll at least let you see the computer's final messages.

Kernel Parameters: A Safe Mode If even the hypervisor serial console doesn't work-that is, if the machine is really really frozen-there are some kernel parameters that we've had good luck with in the past. frozen-there are some kernel parameters that we've had good luck with in the past.

The ignorebiostables ignorebiostables option to the Linux kernel (on the option to the Linux kernel (on the module module line) may help to avoid hangs when under I/O stress on certain Intel chipsets. If your machine is crashing-the hardware is full-on ceasing to function-it might be worth a shot. (I know, it's only one step removed from waving a dead chicken over the server, but you work with what you've got.) line) may help to avoid hangs when under I/O stress on certain Intel chipsets. If your machine is crashing-the hardware is full-on ceasing to function-it might be worth a shot. (I know, it's only one step removed from waving a dead chicken over the server, but you work with what you've got.) In a similar vein, acpi=off acpi=off and and nousb nousb have been reported to improve stability on some hardware. You may also want to disable hyperthreading in the BIOS. Some Xen versions have had trouble with it. have been reported to improve stability on some hardware. You may also want to disable hyperthreading in the BIOS. Some Xen versions have had trouble with it.

If you want to add all of these options at once, your /boot/grub/menu.lst /boot/grub/menu.lst entry for Xen will look something like this: entry for Xen will look something like this: roothd0(0) kernel/boot/xen-3.0.gz module/boot/vmlinuz-2.6-xenignorebiostablesacpi=offnoapicnousb

Getting Help You can, of course, email us directly with Xen-related questions. No guarantee that we'll be able to help, but asking is easy enough. There's also a list of Xen consultants on the Xen wiki at http://wiki.xensource.com/xenwiki/Consultants. (If you happen to be a Xen consultant, feel free to add yourself.) Mailing Lists There are several popular mailing lists devoted to Xen. You can sign up and read digests at http://lists.xensource.com/. We recommend reading the Xen-users mailing list at least. Xen-devel can be interesting, but the high volume of patches might discourage people who aren't actively involved in Xen development. At any rate, both lists are good places to look for help, but Xen-users is a much better place to start if you have a question that involves using using Xen, rather than hacking at it. Xen, rather than hacking at it.

The Xen Wiki Xen has a fairly extensive wiki at http://wiki.xensource.com/. Some of it is out of date, but it's still a valuable starting point. Of course, new contributors are always welcome. Take a look, poke around, and add your own experiences, tips, and cool tidbits.

The Xen IRC Channel There's a fairly popular Xen IRC channel, #xen #xen on on irc.oftc.net irc.oftc.net. Feel free to stop by and chat.

Bugzilla Xen maintains a bug database, just like all software projects above a certain size. It's publicly accessible at http://bugzilla.xensource.com/. Type keywords into the search box, press the b.u.t.ton, and read the results.

Your Distro Vendor Don't forget the specific doc.u.mentation and support resources of your vendor. Xen is a complex piece of software, and the specifics of how it's integrated vary between distros. Although the distro doc.u.mentation may not be as complete as, say, this book, it's likely to at least point in the correct direction.

xen-bugtool If all else fails, you can use xen-bugtool xen-bugtool to annoy the developers directly. The purpose of to annoy the developers directly. The purpose of xen-bugtool xen-bugtool is to collect the relevant troubleshooting information so you can conveniently attach it to a bug report or make it available to a mailing list. is to collect the relevant troubleshooting information so you can conveniently attach it to a bug report or make it available to a mailing list.

Simply run xen-bugtool xen-bugtool on the affected box (in the dom0, of course). It'll start an interactive session and ask you what data to include and what to do with the data. on the affected box (in the dom0, of course). It'll start an interactive session and ask you what data to include and what to do with the data.

The xen-bugtool xen-bugtool script collects the following information: script collects the following information: 1. The output of xm dmesg xm dmesg 2. The output of xm info xm info 3. /var/log/messages (if desired) (if desired) 4. /var/log/xen/xend-debug.log (if desired) (if desired) 5. /var/log/xen/xen-hotplug.log 6. /var/log/xen/xend.log xen-bugtool will save this data as a will save this data as a .tar.bz2 .tar.bz2, after which it's up to you to decide what to do with it. We recommend uploading it somewhere web-accessible and sending a message to the Xen-devel mailing list.

Some Last Words of Encouragement This chapter describes a troubleshooting work flow that works for us. In general, we try to hit the obvious stuff before escalating to more invasive and labor-intensive methods.

We've also tried to list error messages that we've seen, along with possible solutions. Obviously, we can't be encyclopedic, but we've probably hit most of the common error messages in our years working with Xen, and we can at least give you a decent starting point.

Don't get depressed! Concentrate! Remember that the odds are very good that someone has seen and solved this problem before. And, don't forget: There's no shame in giving up occasionally. You can't beat the computer all the time. Well, maybe you can, but we can't. Good luck.

AppendixA.XM REFERENCE

The xm xm command is probably the first thing to know about Xen. It's your primary interface to Xen's control-plane functionality. Using command is probably the first thing to know about Xen. It's your primary interface to Xen's control-plane functionality. Using xm xm, you can create, query, and destroy domains. You can send certain instructions (e.g., shut down) to guest domains. You can attach and detach storage and network devices and dynamically adjust resource consumption.

In short, knowing xm xm is is important important. That's why we've doc.u.mented xm xm 's subcommands here, with references to the rest of the book. 's subcommands here, with references to the rest of the book.

NoteSome of these commands-the ones introduced with Xen 3.1 or later-may not work with the Xen version included in RHEL 5.x because Red Hat's priority is to maintain compatibility within major releases, rather than support new features. These commands are marked with an asterisk because Red Hat's priority is to maintain compatibility within major releases, rather than support new features. These commands are marked with an asterisk.

All of xm xm's commands work by sending instructions to xend xend, the Xen control daemon. This is a Python program that runs in domain 0. It receives requests and sends replies to client applications, like xm xm.

If xend xend isn't running, isn't running, xm xm will return an error and exit. Much of will return an error and exit. Much of xm xm's functionality relies on the XenBus, which is a shared communication channel between all domains on the machine, and the XenStore, which is a centralized configuration database that xend xend uses to hold domain configuration information and states. For more information on the XenStore and XenBus, take a look at uses to hold domain configuration information and states. For more information on the XenStore and XenBus, take a look at Chapter14 Chapter14.

That said, let's look at the general form of an xm xm command. command.

xm's Syntax xm's syntax is fairly simple and consistent: xm[options]

Options can go either before or after the domain specifier, but we usually put them at the end. For example, to order domain 10 to shut down cleanly: xmshutdown10 Here we're not specifying any options, and we're referring to the domain by numeric ID rather than name. The domain specifier may be either a domain number or domain name-the names will be internally translated to numbers. (Note that this won't work if the XenStore isn't up, but in that case, you have bigger problems.) xm commands are usually asynchronous, which means that the command may return before it's actually completed. In the case of a command like commands are usually asynchronous, which means that the command may return before it's actually completed. In the case of a command like xm shutdown xm shutdown, it may take the domain several minutes to actually shut down. In that case, we ordinarily poll xm list xm list to make sure that the domain has stopped running. to make sure that the domain has stopped running.

xm Subcommands Here's a list of the various xm xm subcommands. We use some of them frequently, and we don't use some of them at all. New commands with version 3.1 are marked with an asterisk (*) because version 3.1 marks a substantial change in Xen's approach to domain management. As we mentioned earlier, this means they might also not work with RHEL 5. subcommands. We use some of them frequently, and we don't use some of them at all. New commands with version 3.1 are marked with an asterisk (*) because version 3.1 marks a substantial change in Xen's approach to domain management. As we mentioned earlier, this means they might also not work with RHEL 5.x. Although RHEL 5.2, for example, uses the 3.1 version of the Xen hypervisor, it uses the 3.0.3 versions of the users.p.a.ce tools, such as xend xend.

addlabel, cfgbootpolicy cfgbootpolicy, dumppolicy dumppolicy, getlabel getlabel, labels labels, loadpolicy loadpolicy, makepolicy makepolicy, resources resources, and rmlabel rmlabel These subcommands interface with Xen's security policy infrastructure. As we mention in Chapter14 Chapter14, we haven't seen any practical use for Xen's security policies. If you're interested in more information about the security modules (which are themselves the subject of ongoing work), we suggest looking at the sample policies included with the Xen source distribution.

block-attach, block-configure block-configure, block-detach block-detach, and block-list block-list The various block block subcommands manage storage devices that are attached to domains. These commands are handled in more detail in subcommands manage storage devices that are attached to domains. These commands are handled in more detail in Chapter4 Chapter4.

console The console subcommand attaches to the given domain's console. Note that this is only useful if the domain is set up to use Xen's virtual console.Even if everything is set up correctly, you may need to press ENTER to make it give you a login prompt. (This can be puzzling for new users, who type xm console xm console and see a blank screen, because nothing's been added to the console buffer since the last time they used it.) and see a blank screen, because nothing's been added to the console buffer since the last time they used it.) create The xm create xm create subcommand, in recent versions of Xen, is a synonym for subcommand, in recent versions of Xen, is a synonym for xm new xm new followed by followed by xm start xm start. It's the subcommand we use throughout the book to make domains go.Create expects the name of a config file. If you don't specify a file, it uses the default, expects the name of a config file. If you don't specify a file, it uses the default, /etc/xen/xmdefconfig /etc/xen/xmdefconfig.The create create subcommand takes these options: subcommand takes these options: -h: Prints help.

-q: Quiet mode.

--path: Base path for domain configuration files (/etc/xen by default). by default).

-n: Dry-run mode. Prints the configuration that would be generated. This is used to debug Python code in domain configurations. If you're autogenerating a domain config, it's nice to have some way to test it.

-x: Similar to -n -n but outputs a domain definition in XML. Note that, as of Xen 3.3, this option still relies on the deprecated but outputs a domain definition in XML. Note that, as of Xen 3.3, this option still relies on the deprecated xml.dom.ext xml.dom.ext module and thus does not work with many Python installations. module and thus does not work with many Python installations.

-c: Connect automatically to the console. This is necessary to interact with PyGRUB.

-s: Skip DTD checking for XML domain configurations.

If you don't give xm create xm create a full path, it will default to looking for the config file in a full path, it will default to looking for the config file in /etc/xen /etc/xen. You can change that with the --path --path option. option.

debug-keys *

The debug-keys debug-keys subcommand interacts with the GDB stub built into Xen, enabling you to send magic keystrokes to control the stub's output. It is likely to be useful only if you're hacking Xen's internals. subcommand interacts with the GDB stub built into Xen, enabling you to send magic keystrokes to control the stub's output. It is likely to be useful only if you're hacking Xen's internals.Note that this will only have an effect if you've built Xen with the GDB stub.

*** You are reading on https://webnovelonline.com ***

delete *

rename The xm rename xm rename subcommand allows the administrator to change the human-readable name a.s.sociated with the domain ID. subcommand allows the administrator to change the human-readable name a.s.sociated with the domain ID.

restore and and save save The xm restore xm restore and and save save subcommands complement each other. As we describe in subcommands complement each other. As we describe in Chapter9 Chapter9, xm save xm save causes a domain to relinquish its resources and save state to a save file, and causes a domain to relinquish its resources and save state to a save file, and xm restore xm restore causes it to restore itself from a previously created save file. This is very much like hibernation. causes it to restore itself from a previously created save file. This is very much like hibernation.

resume *

The resume subcommand instructs a domain to return from a suspended state. Note that this only applies to domains managed by xend xend lifecycle support lifecycle support, which is essentially the ability to have xend xend manage inactive domains. manage inactive domains.

sched-credit The credit scheduler is the default scheduler for Xen. The sched-credit sched-credit subcommand configures the credit scheduler, allowing you to display or adjust a domain's weight and cap. We describe its use at some length in subcommand configures the credit scheduler, allowing you to display or adjust a domain's weight and cap. We describe its use at some length in Chapter7 Chapter7.

sched-sedf The sedf scheduler, of course, is obsolete. However, if you find yourself using it, you can use the sched-sedf sched-sedf subcommand to adjust the scheduling parameters for a domain. subcommand to adjust the scheduling parameters for a domain.

sh.e.l.l *

The sh.e.l.l sh.e.l.l subcommand is a bit interesting. It starts an interactive sh.e.l.l, nicknamed subcommand is a bit interesting. It starts an interactive sh.e.l.l, nicknamed The Xen Master The Xen Master, from which you can issue the various xm xm subcommands. subcommands.

shutdown Like xm reboot xm reboot, the shutdown shutdown subcommand orders the domain to shut down, with the difference that it doesn't immediately restart it. This subcommand requires domU cooperation; if the domain doesn't shut down, subcommand orders the domain to shut down, with the difference that it doesn't immediately restart it. This subcommand requires domU cooperation; if the domain doesn't shut down, xend xend won't forcefully terminate it. If won't forcefully terminate it. If xm shutdown xm shutdown doesn't work, you may want to try doesn't work, you may want to try xm destroy xm destroy.

start *

The start start subcommand starts a managed domain. Note that this subcommand, like subcommand starts a managed domain. Note that this subcommand, like new new and and suspend suspend, only exists as of Xen 3.1, which adds xend xend lifecycle support. lifecycle support.

suspend *

The xm suspend xm suspend subcommand suspends a managed domain. subcommand suspends a managed domain.

sysrq The sysrq sysrq subcommand sends one of the magic sysrq keys to the domU. Note that this can't be done via subcommand sends one of the magic sysrq keys to the domU. Note that this can't be done via xm xm console because the dom0 won't pa.s.s a sysrq through to the domU. It's a useful last resort if the domain seems catatonic. For more information about sysrq, see the kernel doc.u.mentation ( console because the dom0 won't pa.s.s a sysrq through to the domU. It's a useful last resort if the domain seems catatonic. For more information about sysrq, see the kernel doc.u.mentation (Doc.u.mentation/sysrq.txt in the Linux kernel source tree). in the Linux kernel source tree).

top The xm top xm top subcommand presents status information for the running Xen domains in a format similar to that of the subcommand presents status information for the running Xen domains in a format similar to that of the top(1) top(1) subcommand. subcommand.

trigger *

The trigger trigger subcommand sends a CPU event to a domain. It can trigger a Non-Maskable Interrupt (NMI), reset, or init event (although the latter two fail with a subcommand sends a CPU event to a domain. It can trigger a Non-Maskable Interrupt (NMI), reset, or init event (although the latter two fail with a function not implemented function not implemented message on Xen 3.2/i386). This subcommand is useful mostly for debugging. message on Xen 3.2/i386). This subcommand is useful mostly for debugging.

unpause The xm unpause xm unpause subcommand resumes a domain that's been paused with subcommand resumes a domain that's been paused with xm pause xm pause.

uptime The xm uptime xm uptime subcommand will print the uptime for the selected domain or for all VMs if no domain is specified. subcommand will print the uptime for the selected domain or for all VMs if no domain is specified.

vcpu-list, vcpu-pin vcpu-pin, and vcpu-set vcpu-set The vcpu- vcpu- subcommands control which subcommands control which cpus cpus a domain will use in an SMP system. For more information, see a domain will use in an SMP system. For more information, see Chapter7 Chapter7.

vnet-create, vnet-delete vnet-delete, and vnet-list vnet-list These three vnet- vnet- subcommands interact with Xen's VLAN support. We don't cover the VLAN support because we've never had occasion to use it and we've never seen anyone else use it. If you're finding it useful, drop us an email. subcommands interact with Xen's VLAN support. We don't cover the VLAN support because we've never had occasion to use it and we've never seen anyone else use it. If you're finding it useful, drop us an email.

vtpm-list The vtpm-list vtpm-list subcommand allows you to list the virtual TPMs (trusted platform modules) that are attached to a domain. Although we don't go into much detail about the TPM, we do refer to it a bit in subcommand allows you to list the virtual TPMs (trusted platform modules) that are attached to a domain. Although we don't go into much detail about the TPM, we do refer to it a bit in Chapter14 Chapter14.

*** You are reading on https://webnovelonline.com ***

Popular Novel