Category: virtualization

  • IPv6 Multicast support on libvirt guests using macvtap

    #
    # Debian / libvirt
    #
    
    # By default, qemu guests network interfaces are created with the
    # trustGuestRxFilters attribute set to no.  This setting blocks
    # neighbor solicitation and other ipv6 multicast traffic.  To enable
    # neighbor solicitations, modify your interface definition in your
    # guest definition XML.
    
    # For example if you have a guest named bird0 with an interface
    # definition that looks like this:
    
    $ sudo virsh dumpxml bird0 | grep -A7 "type='direct'"
        <interface type='direct' trustGuestRxFilters='no'>
          <mac address='52:54:00:AA:BB:CC'/>
          <source dev='ens2f0np0' mode='bridge'/>
          <target dev='macvtap3'/>
          <model type='virtio'/>
          <alias name='net4'/>
          <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
        </interface>
    
    # Then use 'virsh edit bird0' change the attribute in the <interface>
    # element to have the value 'yes' instead:
        <interface type='direct' trustGuestRxFilters='yes'>
          <mac address='52:54:00:AA:BB:CC'/>
          <source dev='ens2f0np0' mode='bridge'/>
          <target dev='macvtap3'/>
          <model type='virtio'/>
          <alias name='net4'/>
          <address type='pci' domain='0x0000' bus='0x09' slot='0x00' function='0x0'/>
        </interface>
    
    # If the trustGuestRxFilters attribute is missing, it defaults to no,
    # so be sure that the attribute exists and that the attribute has a
    # value of 'yes'
    
  • Converting a windows install to a libvirt VM

    Reduce the size of your c: partition to the smallest it can be and then turn off windows with the understanding that you will never boot this system on the iron ever again.
    Boot into a netinst installer image (no GUI). hold alt and press left arrow a few times until you get to a prompt to press enter. Press enter.

    In this example /dev/sda is your windows disk which contains the c: partition
    and /dev/disk/by-id/usb0 is the USB-3 attached SATA controller that you have your SSD attached to (please find an example attached). This SSD should be equal to or larger than the windows disk for best compatability.

    A photo of a USB-3 attached SATA controller

    To find the literal path names of your detected drives you can run fdisk -l. Pay attention to the names of the partitions and the sizes of the drives to help determine which is which.

    Once you have a shell in the netinst installer, you should maybe be able to run a command like the following. This will duplicate the disk located at if (in file) to the disk located at of (out file) while showing progress as the status.

    dd if=/dev/sda of=/dev/disk/by-id/usb0 status=progress

    If you confirm that dd is available on the netinst image and the previous command runs successfully, test that your windows partition is visible in the new disk’s partition table. The start block of the windows partition on each should match, as should the partition size.

    fdisk -l /dev/disk/by-id/usb0
    fdisk -l /dev/sda

    If the output from the first is the same as the output from the second, then you are probably safe to proceed.

    Once you confirm that you have made and tested a full copy of the blocks from your windows drive saved on your usb disk, nuke your windows partition table from orbit.

    dd if=/dev/zero of=/dev/sda bs=1M count=42

    You can press alt-f1 to return to the Debian installer now. Follow the instructions to install Debian. Don’t forget to remove all attached USB drives.

    Once you install Debian, press ctrl-alt-f3 to get a root shell.

    Add your user to the sudoers group:

    # adduser cjac sudoers

    log out

    # exit

    log in as your user and confirm that you have sudo

    $ sudo ls

    Don’t forget to read the spider man advice

    enter your password

    you’ll need to install virt-manager. I think this should help:

    $ sudo apt-get install virt-manager libvirt-daemon-driver-qemu qemu-system-x86

    insert the USB drive. You can now create a qcow2 file for your virtual machine.

    $ sudo qemu-img convert -O qcow2 \
    /dev/disk/by-id/usb0 \
    /var/lib/libvirt/images/windows.qcow2

    I personally create a volume group called /dev/vg00 for the stuff I want to run raw and instead of converting to qcow2 like all of the other users do, I instead write it to a new logical volume.

    sudo lvcreate /dev/vg00 -n windows -L 42G # or however large your drive was
    sudo dd if=/dev/disk/by-id/usb0 of=/dev/vg00/windows status=progress

    Now that you’ve got the qcow2 file created, press alt-left until you return to your GDM session.

    The apt-get install command above installed virt-manager, so log in to your system if you haven’t already and open up gnome-terminal by pressing the windows key or moving your mouse/gesture to the top left of your screen. Type in gnome-terminal and either press enter or click/tap on the icon.

    I like to run this full screen so that I feel like I’m in a space ship. If you like to feel like you’re in a spaceship, too, press F11.

    You can start virt-manager from this shell or you can press the windows key and type in virt-manager and press enter. You’ll want the shell to run commands such as virsh console windows or virsh list

    When virt-manager starts, right click on QEMU/KVM and select New.

    In the New VM window, select “Import existing disk image”

    When prompted for the path to the image, use the one we created with sudo qemu-img convert above.

    Select the version of Windows you want.

    Select memory and CPUs to allocate to the VM.

    Tick the Customize configuration before install box

    If you’re prompted to enable the ‘default’ network, do so now.

    The default hardware layout should probably suffice. Get it as close to the underlying hardware as it is convenient to do. But Windows is pretty lenient these days about virtualizing licensed windows instances so long as they’re not running in more than one place at a time.

    Good luck! Leave comments if you have questions.

  • First taste of Debian 12

    As some of you may know, the Debian project released v12, bookworm to stable on the 10th of this month. I haven’t had a reason to try it yet, but I’m downloading it now. My first thought is that it’s much larger than I expected. The normal sized version used to fit on a CD-ROM disk, so around 650MB. The netinst has until now been even smaller, with the most recent versions being about 256MB if I recall correctly. The netinst, now with proprietary firmware, weighs in over 700MB:

    2023-06-18 20:29:29 (6.85 MB/s) - ‘debian-12.0.0-amd64-netinst.iso’ saved [773849088/773849088]

    It looks like 738.0MB!

    The system I’m installing is for a piece of software I’m crafting for use by Remote Online Notaries. I’m building a disk image for the notary’s side of the connection. The notary will have a yubikey-style PGP card which they will use as a digital seal similar to the one required to perform notarial acts for the state of washington. I’ll leave some ramblings on the blog as I go through the process of implementation. Here’s a link to whet your appetite!

    https://app.leg.wa.gov/wac/default.aspx?cite=308-30-020

  • Early Access: Inserting JSON data to BigQuery from Spark on Dataproc

    Hello folks!

    We recently received a case letting us know that Dataproc 2.1.1 was unable to write to a BigQuery table with a column of type JSON. Although the BigQuery connector for Spark has had support for JSON columns since 0.28.0, the Dataproc images on the 2.1 line still cannot create tables with JSON columns or write to existing tables with JSON columns.

    The customer has graciously granted permission to share the code we developed to allow this operation. So if you are interested in working with JSON column tables on Dataproc 2.1 please continue reading!

    Use the following gcloud command to create your single-node dataproc cluster:

    IMAGE_VERSION=2.1.1-debian11
    REGION=us-west1
    ZONE=${REGION}-a
    CLUSTER_NAME=pick-a-cluster-name
    gcloud dataproc clusters create ${CLUSTER_NAME} \
        --region ${REGION} \
        --zone ${ZONE} \
        --single-node \
        --master-machine-type n1-standard-4 \
        --master-boot-disk-type pd-ssd \
        --master-boot-disk-size 50 \
        --image-version ${IMAGE_VERSION} \
        --max-idle=90m \
        --enable-component-gateway \
        --scopes 'https://www.googleapis.com/auth/cloud-platform'
    

    The following file is the Scala code used to write JSON structured data to a BigQuery table using Spark. The file following this one can be executed from your single-node Dataproc cluster.

    Main.scala

    import org.apache.spark.sql.functions.col
    import org.apache.spark.sql.types.{Metadata, StringType, StructField, StructType}
    import org.apache.spark.sql.{Row, SaveMode, SparkSession}
    import org.apache.spark.sql.avro
    import org.apache.avro.specific
    
      val env = "x"
      val my_bucket = "cjac-docker-on-yarn"
      val my_table = "dataset.testavro2"
        val spark = env match {
          case "local" =>
            SparkSession
              .builder()
              .config("temporaryGcsBucket", my_bucket)
              .master("local")
              .appName("isssue_115574")
              .getOrCreate()
          case _ =>
            SparkSession
              .builder()
              .config("temporaryGcsBucket", my_bucket)
              .appName("isssue_115574")
              .getOrCreate()
        }
    
      // create DF with some data
      val someData = Seq(
        Row("""{"name":"name1", "age": 10 }""", "id1"),
        Row("""{"name":"name2", "age": 20 }""", "id2")
      )
      val schema = StructType(
        Seq(
          StructField("user_age", StringType, true),
          StructField("id", StringType, true)
        )
      )
    
      val avroFileName = s"gs://${my_bucket}/issue_115574/someData.avro"
      
      val someDF = spark.createDataFrame(spark.sparkContext.parallelize(someData), schema)
      someDF.write.format("avro").mode("overwrite").save(avroFileName)
    
      val avroDF = spark.read.format("avro").load(avroFileName)
      // set metadata
      val dfJSON = avroDF
        .withColumn("user_age_no_metadata", col("user_age"))
        .withMetadata("user_age", Metadata.fromJson("""{"sqlType":"JSON"}"""))
    
      dfJSON.show()
      dfJSON.printSchema
    
      // write to BigQuery
      dfJSON.write.format("bigquery")
        .mode(SaveMode.Overwrite)
        .option("writeMethod", "indirect")
        .option("intermediateFormat", "avro")
        .option("useAvroLogicalTypes", "true")
        .option("table", my_table)
        .save()
    
    
    

    repro.sh:

    #!/bin/bash
    
    PROJECT_ID=set-yours-here
    DATASET_NAME=dataset
    TABLE_NAME=testavro2
    
    # We have to remove all of the existing spark bigquery jars from the local
    # filesystem, as we will be using the symbols from the
    # spark-3.3-bigquery-0.30.0.jar below.  Having existing jar files on the
    # local filesystem will result in those symbols having higher precedence
    # than the one loaded with the spark-shell.
    sudo find /usr -name 'spark*bigquery*jar' -delete
    
    # Remove the table from the bigquery dataset if it exists
    bq rm -f -t $PROJECT_ID:$DATASET_NAME.$TABLE_NAME
    
    # Create the table with a JSON type column
    bq mk --table $PROJECT_ID:$DATASET_NAME.$TABLE_NAME \
      user_age:JSON,id:STRING,user_age_no_metadata:STRING
    
    # Load the example Main.scala 
    spark-shell -i Main.scala \
      --jars /usr/lib/spark/external/spark-avro.jar,gs://spark-lib/bigquery/spark-3.3-bigquery-0.30.0.jar
    
    # Show the table schema when we use `bq mk --table` and then load the avro
    bq query --use_legacy_sql=false \
      "SELECT ddl FROM $DATASET_NAME.INFORMATION_SCHEMA.TABLES where table_name='$TABLE_NAME'"
    
    # Remove the table so that we can see that the table is created should it not exist
    bq rm -f -t $PROJECT_ID:$DATASET_NAME.$TABLE_NAME
    
    # Dynamically generate a DataFrame, store it to avro, load that avro,
    # and write the avro to BigQuery, creating the table if it does not already exist
    
    spark-shell -i Main.scala \
      --jars /usr/lib/spark/external/spark-avro.jar,gs://spark-lib/bigquery/spark-3.3-bigquery-0.30.0.jar
    
    # Show that the table schema does not differ from one created with a bq mk --table
    bq query --use_legacy_sql=false \
      "SELECT ddl FROM $DATASET_NAME.INFORMATION_SCHEMA.TABLES where table_name='$TABLE_NAME'"
    

    Google BigQuery has supported JSON data since October of 2022, but until now, it has not been possible, on generally available Dataproc clusters, to interact with these columns using the Spark BigQuery Connector.

    JSON column type support was introduced in spark-bigquery-connector release 0.28.0.

  • Instructions for installing Proxmox onto the Qotom device

    These instructions are for qotom devices Q515P and Q1075GE. You can order one from Amazon or directly from Cherry Ni <export03@qotom.com>. Instructions are for those coming from Windows.

    Prerequisites:

    • A USB keyboard and mouse
    • A powered HDMI monitor and an HDMI cable
    • A copy of the Proxmox VE Installer ISO
    • A USB disk from which to boot the installer
    • Software and instructions to burn the raw image to USB
    • The details of your wireless network including wireless network ID (SSID), WPA password, gateway address and network prefix length

    To find your windows network details, run the following command at the command prompt:

    netsh interface ip show addresses

    Here’s my output:

    PS C:\Users\cjcol> netsh interface ip show addresses "Wi-Fi"
    
    Configuration for interface "Wi-Fi"
        DHCP enabled:                         Yes
        IP Address:                           172.16.79.53
        Subnet Prefix:                        172.16.79.0/24 (mask 255.255.255.0)
        Default Gateway:                      172.16.79.1
        Gateway Metric:                       0
        InterfaceMetric:                      50
    

    Did you follow the instructions linked above in the “prerequisites” section? If not, take a moment to do so now.
    Open Rufus and select the proxmox iso which you downloaded.

    You may be warned that Rufus will be acting as dd.

    Don’t forget to select the USB drive that you want to write the image to. In my example, the device is creatively called “NO_LABEL”.

    You may be warned that re-imaging the USB disk will result in the previous data on the USB disk being lost.

    Once the process is complete, the application will indicate that it is complete.

    You should now have a USB disk with the Proxmox installer image on it. Place the USB disk into one of the blue, USB-3.0, USB-A slots on the Qotom device so that the system can read the installer image from it at full speed. The Proxmox installer requires a keyboard, video and mouse. Please attach these to the device along with inserting the USB disk you just created.

    Press the power button on the Qotom device. Press the F11 key repeatedly until you see the AMI BIOS menu. Press F11 a couple more times. You’ll be presented with a boot menu. One of the options will launch the Proxmox installer. By trial and error, I found that the correct boot menu option was “UEFI OS”

    Once you select the correct option, you will be presented with a menu that looks like this. Select the default option and install.

    During the install, you will be presented with an option of the block device to install to. I think there’s only a single block device in this celeron, but if there are more than one, I prefer the smaller one for the ProxMox OS. I also make a point to limit the size of the root filesystem to 16G. I think it will take up the entire volume group if you don’t set a limit.

    Okay, I’ll do another install and select the correct filesystem.

    If you read this far and want me to add some more screenshots and better instructions, leave a comment.

  • IPv6 with CenturyLink Fiber

    In case you want to know how to configure IPv6 using CenturyLink’s 6rd tunneling service.

    There are four files to update with my script:

    There are a couple of environment variables in /etc/default/centurylink-6rd that you will want to set. Mine looks like this:

    LAN_IFACE="ens18,ens21,ens22"
    HEADER_FILE=/etc/radvd.conf.header
    

    The script will configure radvd to advertise v6 routes to a /64 of clients on each of the interfaces delimited by a comma in LAN_IFACE. Current interface limit is 9. I can patch something to go up to 0xff, but I don’t want to at this time.

    If you have some static configuration that you want to preserve, place them into the file pointed to by ${HEADER_FILE} and it will be prepended to the generated /etc/radvd.conf file. The up script will remove the file and re-create it every time your ppp link comes up, so keep that in mind and don’t manually modify the file and expect it to perist. You’ve been warned :-)

    So here’s the script. It’s also linked above if you want to curl it.

    #!/bin/bash
    #
    # Copyright 2023 Collier Technologies LLC
    # https://wp.c9h.org/cj/?p=1844
    #
    
    # # These variables are for the use of the scripts run by run-parts
    # PPP_IFACE="$1"
    # PPP_TTY="$2"
    # PPP_SPEED="$3"
    # PPP_LOCAL="$4"
    # PPP_REMOTE="$5"
    # PPP_IPPARAM="$6"
    
    ${PPP_IFACE:="ppp0"}
    if [[ -z ${PPP_LOCAL} ]]; then
        PPP_LOCAL=$(curl -s https://icanhazip.com/)
    fi
    
    6rd_prefix="2602::/24"
    
    #printf "%x%x:%x%x\n" $(echo $PPP_LOCAL | tr . ' ')
    
    # This configuration option came from CenturyLink:
    # https://www.centurylink.com/home/help/internet/modems-and-routers/advanced-setup/enable-ipv6.html
    border_router=205.171.2.64
    
    TUNIFACE=6rdif
    
    first_ipv6_network=$(printf "2602:%02x:%02x%02x:%02x00::" $(echo ${PPP_LOCAL} | tr . ' '))
    
    ip tunnel del ${TUNIFACE} 2>/dev/null
    ip -l 5 -6 addr flush scope global dev ${IFACE}
    
    ip tunnel add ${TUNIFACE} mode sit local ${PPP_LOCAL} remote ${border_router}
    ip tunnel 6rd dev ${TUNIFACE} 6rd-prefix "${first_ipv6_network}0/64" 6rd-relay_prefix ${border_router}/32
    ip link set up dev ${TUNIFACE}
    ip -6 route add default dev ${TUNIFACE}
    
    ip addr add ${first_ipv6_network}1/64 dev ${TUNIFACE}
    
    rm /etc/radvd.conf
    i=1
    DEFAULT_FILE="/etc/default/centurylink-6rd"
    if [[ -f ${DEFAULT_FILE} ]]; then
        source ${DEFAULT_FILE}
        if [[ -f ${HEADER_FILE} ]]; then
    	cp ${HEADER_FILE} /etc/radvd.conf
        fi
    else
        LAN_IFACE="setThis"
    fi
       
    for IFACE in $( echo ${LAN_IFACE} | tr , ' ' ) ; do
    
        ipv6_network=$(printf "2602:%02x:%02x%02x:%02x0${i}::" $(echo ${PPP_LOCAL} | tr . ' '))
    
        ip addr add ${ipv6_network}1/64 dev ${TUNIFACE}
        ip -6 route replace "${ipv6_network}/64" dev ${IFACE} metric 1
    
        echo "
    interface ${IFACE} {
       AdvSendAdvert on;
       MinRtrAdvInterval 3;
       MaxRtrAdvInterval 10;
       AdvLinkMTU 1280;
       prefix ${ipv6_network}/64 {
         AdvOnLink on;
         AdvAutonomous on;
         AdvRouterAddr on;
         AdvValidLifetime 86400;
         AdvPreferredLifetime 86400;
       };
    };
    " >> /etc/radvd.conf
    
        let "i=i+1"
    done
    
    systemctl restart radvd
    
  • Using SonarQube 5.4, Maven 3.3.9, Jenkins 2.19.1 on systems with both Java 1.7 and 1.8

    Hello folks! My team spent hours and hours beating our head against a Sonar deployment problem on Ubuntu Trusty (14.04 LTS). I thought I might share our findings so that you won’t have to!

    As you probably know, Trusty only makes Java Development Kit 1.7 available on the stock installation. The current stable version of the Java is 1.8. The way we install this is to use the OpenJDK PPA, generously uploaded by our dear friend Matthias Klose.

    To make things even more exciting, a modern Maven is not available on this platform. And so we use the stock Maven 3.3.9 tarball distribution. This tarball distribution does not integrate well with Debian, and so, when we tell the system using sudo update-java-alternatives -s /usr/lib/jvm/java-1.8.0-openjdk-amd64 that we wish to use Java 1.8 as our default system JDK, it does not get the message.

    The only way to reliably let Maven know which java you wish to use is to set the JAVA_HOME environment variable. In order to do this within the Jenkins environment, one must select the JDK one wishes to use:

    openjdk8-ubuntu1404-as-jdk

    To make things worse, this option is not, as one might expect, available for editing in a stock Jenkins 2.x installation. In Jenkins 1.x, one would be able to specify which java one wished to use just by specifying “openjdk8” in a field. With Jenkins 2.x, the field does not exist unless a configuration option in an unrelated form is set.

    So! One should first select Manage Jenkins -> Global Tool Configuration:

    Jenkins2-Global_Tool_Configuration

    Once this form is open, look for the “JDK installations…” button:

    Jenkins2-JDK_installations

    Click it very thoroughly just once.

    You’ll be presented with a form into which you may enter details about the various JDKs your build executors may have access to. You’ll refer to them in your job configuration by the value of their “Name” field, and when executing the build, Jenkins will set JAVA_HOME to the value of the (you guessed it) JAVA_HOME field:

    Jenkins2-JDK_installations-expanded

    Once these entries are made, they can be selected in two place.

    1) on the ZMQ Event Publisher:

    jdk-select-project

    2) in the post-build actions under SonarQube analysis with Maven (advanced)

    postbuild-sonarqube-select-jdk

    And that’s how it’s done!

    Here’s the details from my colleague, Thanh:

    https://lists.fd.io/pipermail/honeycomb-dev/2016-October/000387.html

  • OpenDaylight Symposium 2016

    I’ll write this later.  Keywords and notes inline

    Cloud

    5G

    AT&T

    Ericsson

    SDN

    FD.io

    Cisco

    Intel

    Linux

    Debian

    Ubuntu

    Open Source

    Hydrogen

    Helium

    Lithium

    OSI stack

    Usability

    Developers and users working together.

    Fast Dev/Test cycles

    Sessions start at 10:30

    Message bus

    Minimal install needs to be smaller

    Most functionalities must be implemented in modules

    Upgrade path complexity

    Out of band control channel.
    OPNFV customers don’t run stock releases, make customisations and plugins easier.

    Message bus

    Distribution vendors should not be expected to perform package maintenance.  Get the distribution ready for fast pathing in to backports, security, testing  and unstable.

  • virt manager cannot find suitable emulator for x86 64

    Looks like I was missing qemu-kvm.

    $ sudo apt-get install qemu-kvm qemu-system

  • Some work on a VyOS image with Let’s Encrypt certs

    I put some packages together this weekend. It’s been a while since I’ve debuilt anything officially.

    The plan is to build a binding to the libgnutls.so.30 API. The certtool CSR (REQ) generation interface does not allow me to create a CRL with “not critical” attributes set on purposes. Maybe if I do it a bit closer to the metal it will be easier…