Monday, October 31, 2011

KVM PCI device assignment

My coworker is setting up KVM PCI device assignment to get around a problem he had with assigning more than four drives per server. Normally we'd just use clustered LVM and assign drives directly from the SAN by editing that VMs XML file contained in /etc/libvirt/qemu/ . However, this is the first time we've needed more than four drives per VM and KVM will only allow 4 drives per server since we're limited to a single disk controller.

Update: Turns out this was not a good idea since the VM would monopolize the device on the physical machine; e.g. the VM would get an HBA to the SAN.

Update 2: Using NPIV seems to be the right thing for this.

Monday, October 10, 2011

MySQL: replace into

I am having one of those nights where I appreciate Shlomi Noach's REPLACE INTO: think twice. "REPLACE INTO" is not a conditional insert or update based on if the same key exists. It's better thought of as a conditional insert OR delete then insert query. This will get you if you're trying to do a field_name=field_name in your query to preserve it's value as you would do with an update since the original field_value would be lost. I re-wrote my query to do a "INSERT ... ON DUPLICATE KEY UPDATE" instead.