Skip to content

Instantly share code, notes, and snippets.

View archerslaw's full-sized avatar
:octocat:
Focusing

Archers Law archerslaw

:octocat:
Focusing
View GitHub Profile
@archerslaw
archerslaw / Glusterfs quick start in QEMU.
Last active August 29, 2015 14:00
Glusterfs quick start in QEMU.
1.GlusterFS is an open source, distributed file system capable of scaling to several petabytes (actually, 72 brontobytes!) and handling thousands of clients. GlusterFS clusters together storage building blocks over Infiniband RDMA or TCP/IP interconnect, aggregating disk and memory resources and managing data in a single global namespace. GlusterFS is based on a stackable user space design and can deliver exceptional performance for diverse workloads. Goal of this translator is to use logical volumes to store VM images and expose them as files to QEMU/KVM.
2.Quick start.
1).Install gluster server.
glusterfs-server
https://brewweb.devel.redhat.com/buildinfo?buildID=350720
2).Create brick.
# mkdir -p /home/brick1
3).Start gluster service.
# /bin/systemctl start glusterd.service
@archerslaw
archerslaw / Thinly-provisioned testing.
Last active August 29, 2015 13:59
Thinly-provisioned testing.
Test Matrix:
Filesystem: ext4 and xfs and scsi_debug for host side, and ext4 or xfs for guest side.
Backend: localfile or iSCSI or libiscsi (Note: BZ#1037503 glusterfs not support discard).
Disk Format: RAW for passthrough, RAW/qcow2 for localfile.
Disk Interface: scsi-block/scsi-hd/ide/ahci for UNMAP mode, scsi-block/scsi-hd interface for WRITE SAME mode.
NOTE: Persistent reservations *cannot* be used with discard when QEMU run as non-root user, but can work well in root user.(BZ966883#c5)
Windows only supports automatic discard (like "-o discard" in Linux).
You can check that discard is enabled by running.
@archerslaw
archerslaw / Use the blockdev_add in qemu-kvm.
Last active August 29, 2015 13:59
Use the blockdev_add in qemu-kvm.
##
# @BlockdevOptionsBase
#
# Options that are available for all block devices, independent of the block
# driver.
#
# @driver: block driver name
# @id: #optional id by which the new block device can be referred to.
# This is a required option on the top level of blockdev-add, and
# currently not allowed on any other level.
@archerslaw
archerslaw / cpu_model_definition.
Last active August 29, 2015 13:58
cpu_model_definition.
- AMD & Intel:
Opteron_G4: avx,xsave,aes,sse4.2,sse4.1,cx16,ssse3,sse4a
Opteron_G3: cx16,sse4a
Opteron_G2: cx16
Opteron_G1: no cx16
@archerslaw
archerslaw / bridge&open vswitch network
Last active December 29, 2023 07:04
bridge and open vswitch network configuration.
###### Bridge network configuration.
# cat /etc/qemu-ifup
#!/bin/sh
switch=switch
/sbin/ifconfig $1 0.0.0.0 up
/usr/sbin/brctl addif ${switch} $1
# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
@archerslaw
archerslaw / libvirt_control_qemu_via_virsh.py
Last active August 29, 2015 13:57
libvirt_control_qemu_via_virsh.py
import libvirt
conn = libvirt.open('qemu:///system')
for id in conn.listDomainsID():
dom = conn.lookupByID(id)
print "Dom %s State %s" % ( dom.name(), dom.info()[0] )
dom.suspend()
print "Dom %s State %s (after suspend)" % ( dom.name(), dom.info()[0] )
dom.resume()
print "Dom %s State %s (after resume)" % ( dom.name(), dom.info()[0] )
dom.destroy()
@archerslaw
archerslaw / hotplug-via-QMP.py
Last active September 11, 2018 17:11
hotplug-via-QMP.py
# QEMU Monitor Protocol Python class
#
# Copyright (C) 2009 Red Hat Inc.
#
# This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory.
import socket, json, time, commands
from optparse import OptionParser
@archerslaw
archerslaw / Simple virsh commands.
Last active August 17, 2022 13:38
Simple virsh commands.
# /bin/systemctl restart libvirtd.service
# /bin/systemctl enable libvirtd.service
Note:
How to turn on the debug logs for libvirtd.
1)open /etc/libvirt/libvirtd.conf in your favourite editor.
2)find & replace, or set these variables:
log_level = 1
log_filters="3:remote 4:event 3:json 3:rpc" | log_filters="1:qemu_monitor_json"
log_outputs="1:file:/var/log/libvirt/libvirtd.log"
@archerslaw
archerslaw / Virsh_XML_Configure_Example
Last active August 29, 2015 13:57
Virsh_XML_Configure_Example
<domain type='kvm'>
<name>sluo_kvm_example</name>
<uuid>fd509219-5ace-4102-90bd-d4312a85a363</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
import re
import sys
import os
def filerev(somefile, buffer=256):
somefile.seek(0, os.SEEK_END)
size = somefile.tell()
lines = ['']
rem = size % buffer
pos = max(0, (size // buffer - 1) * buffer)